Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Making an email build past an optional component


jacobr

Recommended Posts

I have the CCGV contribution installed, which gives you the option of including either a gift voucher or discount coupon code in the first email that gets sent to a new customer upon signup.

 

My question is - I'm trying to format the email to fit the look that I want, which places the CCGV code in the middle of the email. The problem is, the code is an optional include. If I don't want there to be either a GV or coupon included, I don't enter parameters in the Admin and that chunk of the email isn't included. See here:

 

 $email_text = EMAIL_SEPARATOR . "\n" . EMAIL_HEADER . "\n" . EMAIL_SEPARATOR . "\n\n";
       
     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;

//  START CCGV ADD  

 if (NEW_SIGNUP_GIFT_VOUCHER_AMOUNT > 0) {
   $coupon_code = create_coupon_code();
   $insert_query = tep_db_query("insert into " . TABLE_COUPONS . " (coupon_code, coupon_type, coupon_amount, date_created) values ('" . $coupon_code . "', 'G', '" . NEW_SIGNUP_GIFT_VOUCHER_AMOUNT . "', now())");
   $insert_id = tep_db_insert_id($insert_query);
   $insert_query = tep_db_query("insert into " . TABLE_COUPON_EMAIL_TRACK . " (coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent) values ('" . $insert_id ."', '0', 'Admin', '" . $email_address . "', now() )");

   $email_text .= sprintf(EMAIL_GV_INCENTIVE_HEADER, $currencies->format(NEW_SIGNUP_GIFT_VOUCHER_AMOUNT)) . "\n\n" .
                  sprintf(EMAIL_GV_REDEEM, $coupon_code) . "\n\n" .
                  EMAIL_GV_LINK . tep_href_link(FILENAME_GV_REDEEM, 'gv_no=' . $coupon_code,'NONSSL', false) .
                  "\n\n";
 }
 if (NEW_SIGNUP_DISCOUNT_COUPON != '') {
 $coupon_code = NEW_SIGNUP_DISCOUNT_COUPON;
   $coupon_query = tep_db_query("select * from " . TABLE_COUPONS . " where coupon_code = '" . $coupon_code . "'");
   $coupon = tep_db_fetch_array($coupon_query);
 $coupon_id = $coupon['coupon_id'];  
   $coupon_desc_query = tep_db_query("select * from " . TABLE_COUPONS_DESCRIPTION . " where coupon_id = '" . $coupon_id . "' and language_id = '" . (int)$languages_id . "'");
   $coupon_desc = tep_db_fetch_array($coupon_desc_query);
   $insert_query = tep_db_query("insert into " . TABLE_COUPON_EMAIL_TRACK . " (coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent) values ('" . $coupon_id ."', '0', 'Admin', '" . $email_address . "', now() )");
   $email_text .= EMAIL_COUPON_INCENTIVE_HEADER . sprintf("%s", $coupon_desc['coupon_description']) . sprintf(EMAIL_COUPON_REDEEM, $coupon['coupon_code']);

//  END CCGV
   
   $email_text .= EMAIL_TEXT2 . EMAIL_SEPARATOR . "\n" . EMAIL_FOOTER1 . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_FOOTER2 . "\n" . EMAIL_SEPARATOR;

 

My problem is that, if I don't have either of these discounting methods included, the $email_text does not continue or skip over the CCGV block and still include the code at the end (EMAIL_TEXT2, etc).

 

How can I tell it to include the bottom of the email no matter what, if there is or isn't a discount coupon/GV included?

 

Jacob

Link to comment
Share on other sites

What about ?

$coupon_desc['coupon_description']) . sprintf(EMAIL_COUPON_REDEEM, $coupon['coupon_code']);
} // end if (NEW_SIGNUP_DISCOUNT_COUPON != '')
// ?END CCGV

? ?$email_text .= EMAIL_TEXT2 . EMAIL_SEPARATOR . "\n" . EMAIL_FOOTER1 . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_FOOTER2 . "\n" . EMAIL_SEPARATOR;

Link to comment
Share on other sites

I got it to skip over and append the end of my email_text if there is no GV or Coupon Code (just needed to move the final email_text that is static out of the if function - oops!) - now I'm struggling with the output if I want to include a discount.

 

The email that it outputs, gives me the EMAIL_COUPON_INCENTIVE_HEADER text, but doesn't continue through that final statement to give me the actual coupon name or the EMAIL_COUPON_REDEEM text. Here's the code again:

 

 if (NEW_SIGNUP_DISCOUNT_COUPON != '') {
 $coupon_code = NEW_SIGNUP_DISCOUNT_COUPON;
   $coupon_query = tep_db_query("select * from " . TABLE_COUPONS . " where coupon_code = '" . $coupon_code . "'");
   $coupon = tep_db_fetch_array($coupon_query);
 $coupon_id = $coupon['coupon_id'];  
   $coupon_desc_query = tep_db_query("select * from " . TABLE_COUPONS_DESCRIPTION . " where coupon_id = '" . $coupon_id . "' and language_id = '" . (int)$languages_id . "'");
   $coupon_desc = tep_db_fetch_array($coupon_desc_query);
   $insert_query = tep_db_query("insert into " . TABLE_COUPON_EMAIL_TRACK . " (coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent) values ('" . $coupon_id ."', '0', 'Admin', '" . $email_address . "', now() )");
  $email_text .= EMAIL_COUPON_INCENTIVE_HEADER . sprintf("%s", $coupon_desc['coupon_description']) . sprintf(EMAIL_COUPON_REDEEM, $coupon['coupon_code']);

}

$email_text .= EMAIL_TEXT2 . EMAIL_SEPARATOR . "\n" . EMAIL_FOOTER1 . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_FOOTER2 . "\n" . EMAIL_SEPARATOR;

 

What can I do to make it output the full statement (EMAIL_COUPON_INCENTIVE_HEADER ... EMAIL_COUPON_REDEEM) at the bottom, rather than just the defined text for EMAIL_COUPON_INCENTIVE_HEADER?

 

Jacob

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...