Forums / Discounts/Coupons, Gift Certificates, Newsletters, Ads / How to create a coupon/discount code for a specific group of email address

How to create a coupon/discount code for a specific group of email address

Views: 1,925

Results 1 to 2 of 2
24 May 2015, 11:07 AM
#1
kman55 avatar

kman55

New Zenner

Join Date:
Feb 2011
Location:
Washington, D.C.
Posts:
80
Plugin Contributions:
0

How to create a coupon/discount code for a specific group of email address

Hello

I am trying to figure out if Zencart can create a coupon that is specific to a domain name. For example: If I want to offer a coupon to just people who use an email address from only @mil.gov or @au.edu etc.

Is there a way to do that? I've been reading and trying to find out if I can do that, and I can't come up with an answer...

http://www.kinkykupid.com. WARNING: Please note that this site is intended to sell Adult Toys, Novelties and Costumes. Please do not click the link if you may find it offensive.

24 May 2015, 5:11 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: How to create a coupon/discount code for a specific group of email address

This could be customized to allow ALL coupons to only be valid for various email addresses by editing the file:
/includes/modules/order_totals/ot_coupon.php

by adding the code in RED: around line 357:

          // remove if fails address validation
          if (!$foundvalid) {
            $messageStack->add_session('checkout_payment', TEXT_REMOVE_REDEEM_COUPON_ZONE, 'caution');
            $this->clear_posts();
            if (!$foundvalid) zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL',true, false));
          } else {
          //      if ($_POST['submit_redeem_coupon_x'] && !$_POST['gv_redeem_code']) zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, 'credit_class_error_code=' . $this->code . '&credit_class_error=' . urlencode(TEST_NO_REDEEM_CODE), 'SSL', true, false));
            $messageStack->add('checkout', TEXT_VALID_COUPON,'success');
          }
        }

[B]        // bof: check customer email address OHIO-USA.COM or MYLINKSTO.COM
        if ($foundvalid) {
          //echo '$order->customer[email_address]: ' . $order->customer['email_address'] . '<br>';
          if (preg_match('#OHIO-USA.COM#i', $order->customer['email_address']) || preg_match('#MYLINKSTO.COM#i', $order->customer['email_address'])) {
            // valid
          } else {
            // not valid
            define('TEXT_INVALID_COUPON_EMAIL', 'Coupon Valid for Customers with emails from OHIO-USA.COM only!');
            $messageStack->add_session('redemptions', TEXT_INVALID_COUPON_EMAIL ,'caution');
            $this->clear_posts();
            zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', true, false));
          }
        }
        // eof: check customer email address OHIO-USA.COM or MYLINKSTO.COM
[/B]
      } else {

Just change the email matches to your own ...

If you want this just for a specific coupon, you would need a bit more customization to reference the specific coupon ...

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!