Forums / Discounts/Coupons, Gift Certificates, Newsletters, Ads / 2nd purchase entitles customer to 10% off, how?

2nd purchase entitles customer to 10% off, how?

Views: 926

Results 1 to 3 of 3
11 Jan 2013, 2:24 AM
#1
chargin avatar

chargin

Zen Follower

Join Date:
Sep 2011
Posts:
136
Plugin Contributions:
0

2nd purchase entitles customer to 10% off, how?

After a customer has made a purchase, I want to be able to offer them 10% off the next purchase, how do I automate that?

13 Jan 2013, 4:00 AM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: 2nd purchase entitles customer to 10% off, how?

You can try adding this to the override file for:
/includes/languages/english/checkout_process.php

 // bof: add Discount Coupon to Order
// set the Discount Coupon to be used for coupon_id as ORDER_DISCOUNT_COUPON
define('ORDER_DISCOUNT_COUPON', '1');
define('EMAIL_COUPON_INCENTIVE_HEADER', 'Congratulations! To make your next visit to our online shop a more rewarding experience, listed below are details for a Discount Coupon created just for you!' . "\n\n");
// your Discount Coupon Description will be inserted before this next define
define('EMAIL_COUPON_REDEEM', 'To use the Discount Coupon, enter the ' . TEXT_GV_REDEEM . ' code during checkout:  <strong>%s</strong>' . "\n\n");
define('TEXT_COUPON_HELP_DATE', '<p>The coupon is valid between %s and %s</p>');
// eof: add Discount Coupon to Order

Then add the code in RED to the:
/includes/classes/order.php

    $html_msg['INTRO_URL_VALUE']       = zen_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $zf_insert_id, 'SSL', false);

[B]// bof: add Discount Coupon to Order
      global $db;
      $email_order_discount .= "\n\n";
      $coupon_id = ORDER_DISCOUNT_COUPON;
      $coupon = $db->Execute("select * from " . TABLE_COUPONS . " where coupon_id = '" . $coupon_id . "'");
      $coupon_desc = $db->Execute("select coupon_description from " . TABLE_COUPONS_DESCRIPTION . " where coupon_id = '" . $coupon_id . "' and language_id = '" . $_SESSION['languages_id'] . "'");
      $db->Execute("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() )");

      $text_coupon_help = sprintf(TEXT_COUPON_HELP_DATE, zen_date_short($coupon->fields['coupon_start_date']),zen_date_short($coupon->fields['coupon_expire_date']));

      // if on, add in Discount Coupon explanation
      //        $email_text .= EMAIL_COUPON_INCENTIVE_HEADER .
      $email_order_discount .= EMAIL_COUPON_INCENTIVE_HEADER .
      (!empty($coupon_desc->fields['coupon_description']) ? $coupon_desc->fields['coupon_description'] . "\n\n" : '') . $text_coupon_help  . "\n\n" .
      strip_tags(sprintf(EMAIL_COUPON_REDEEM, ' ' . $coupon->fields['coupon_code']));

      $html_msg['COUPON_TEXT_VOUCHER_IS'] = EMAIL_COUPON_INCENTIVE_HEADER ;
      $html_msg['COUPON_DESCRIPTION']     = (!empty($coupon_desc->fields['coupon_description']) ? '<strong>' . $coupon_desc->fields['coupon_description'] . '</strong>' : '');
      $html_msg['COUPON_TEXT_TO_REDEEM']  = str_replace("\n", '', sprintf(EMAIL_COUPON_REDEEM, ''));
      $html_msg['COUPON_CODE']  = $coupon->fields['coupon_code'] . $text_coupon_help;

     //comments area
    if ($this->info['comments']) {
      $email_order .= zen_db_output($this->info['comments']) . "\n\n";
      $html_msg['ORDER_COMMENTS'] = nl2br(zen_db_output($this->info['comments']));
    } else {
      $html_msg['ORDER_COMMENTS'] = '';
    }

// add Discount Coupon to TEXT email
    $email_order .= $email_order_discount;
// add Discount Coupon to HTML email
    $html_msg['ORDER_COMMENTS'] .= "<br /><br />" . $email_order_discount;
// eof: add Discount Coupon to Order
[/B]
    //products area
    $email_order .= EMAIL_TEXT_PRODUCTS . "\n" .

This will give them the coupon code in their order-confirmation email every time they place a new order.
You can adjust this as needed but it gives you an idea of how this could be done ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

22 Jan 2013, 11:32 PM
#3
chargin avatar

chargin

Zen Follower

Join Date:
Sep 2011
Posts:
136
Plugin Contributions:
0

Re: 2nd purchase entitles customer to 10% off, how?

Thanks, it will be a while till I try this but looks good.
So every order made at the store will give a code that only that login can use and only once for their next order?