Page 1 of 1

Need Help To Use Else Function

Posted: Mon Feb 21, 2011 8:06 am
by gaspower
Hello,
Need some help with the below code. Currently the below code will send two emails, and that is working fine,

Code: Select all

$name = $firstname . ' ' . $lastname;

      if (ACCOUNT_GENDER == 'true') {
         if ($gender == 'm') {
           $email_text = sprintf(EMAIL_GREET_MR, $lastname);
         } else {
           $email_text = sprintf(EMAIL_GREET_MS, $lastname);
         }
      } else {
        $email_text = sprintf(EMAIL_GREET_NONE, $firstname);
      }

      $email_text .= EMAIL_WELCOME . EMAIL_TEXT . EMAIL_CONTACT . EMAIL_WARNING;
      tep_mail($name, $email_address, EMAIL_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

	$email_text_coupon .= EMAIL_WELCOME . EMAIL_TEXT_COUPON . EMAIL_CONTACT. EMAIL_WARNING;
      tep_mail($name, $email_address, EMAIL_SUBJECT_COUPON, $email_text_coupon, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
I need to be able to option the second email to be sent when the below code is tru,

Code: Select all

if ( ACCOUNT_COMPANY == 'true' && tep_not_null($company_tax_id) ) {
I am just not sure how to implement it to correctly option out the second email. I know I need to use the } else { function, but just can not seem to figure it out.

Thanks for any help.

JR

Re: Need Help To Use Else Function

Posted: Mon Feb 21, 2011 11:35 am
by cpetercarter

Code: Select all

if (ACCOUNT_GENDER == 'true') 
{
// some code
}
elseif (ACCOUNT_COMPANY == 'true' && tep_not_null($company_tax_id) )
{
// some more code
}

Re: Need Help To Use Else Function

Posted: Tue Feb 22, 2011 8:27 am
by gaspower
Hello and thank you for the response,

I tried the below, but for some reason it does not send the second email. I tried both true and false.

Code: Select all

$email_text .= EMAIL_WELCOME . EMAIL_TEXT . EMAIL_CONTACT . EMAIL_WARNING;
      tep_mail($name, $email_address, EMAIL_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
}
elseif (ACCOUNT_COMPANY == 'true' && tep_not_null($company_tax_id) )
{

        $email_text_coupon .= EMAIL_WELCOME . EMAIL_TEXT_COUPON . EMAIL_CONTACT. EMAIL_WARNING;
      tep_mail($name, $email_address, EMAIL_SUBJECT_COUPON, $email_text_coupon, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
Thanks JR

Re: Need Help To Use Else Function

Posted: Thu Feb 24, 2011 1:16 pm
by cpetercarter
Do you mean

Code: Select all

ACCOUNT_COMPANY == 'true'
or

Code: Select all

ACCOUNT_COMPANY == true
They are not the same. The first tests whether ACCOUNT_COMPANY is a string 'true'. The second tests whether it has the boolean value true.