Hi.
I'd like to prevent ppl from redeeming a discount coupon code when their in a discount group. Is that possible?
Hi.
I'd like to prevent ppl from redeeming a discount coupon code when their in a discount group. Is that possible?
Perhaps some background info would help?
I'm doign a WagJaw campaign(CDN groupon clone) and I'm selling a membership that will entitle clients to a discount for a year. I was hoping to use group pricing for this but I hadn't realized they could also redeem coupons on top of the group pricing discount. Is there a way to add restrictions to group pricing or perhaps do this another way. Worst case I guess I could give everone a coupon code they they'd have to enter at every purchase that way they could only apply a single discount but that's allot of overhead when I could just have them part of a group.
Any thoughts?
To stop anyone with a Group Discount from using a Discount Coupon, you could alter the ot_coupon.php module with something like:
Note: you should include some type of exclusion statement in your Discount Coupons ...Code:function credit_selection() { global $discount_coupon; // note the placement of the redeem code can be moved within the array on the instructions or the title // bof: stop discount coupon for anyone in a customer group global $db; $chk_group = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where customers_id = '" . $_SESSION['customer_id'] . "'"); if ($chk_group->fields['customers_group_pricing'] > 0) { $allow_discount = false; } else { $allow_discount = true; } if ($allow_discount) { $selection = array('id' => $this->code, 'module' => $this->title, 'redeem_instructions' => MODULE_ORDER_TOTAL_COUPON_REDEEM_INSTRUCTIONS . ($discount_coupon->fields['coupon_code'] != '' ? MODULE_ORDER_TOTAL_COUPON_REMOVE_INSTRUCTIONS : '') . ($discount_coupon->fields['coupon_code'] != '' ? MODULE_ORDER_TOTAL_COUPON_TEXT_CURRENT_CODE . '<a href="javascript:couponpopupWindow(\'' . zen_href_link(FILENAME_POPUP_COUPON_HELP, 'cID=' . $_SESSION['cc_id']) . '\')">' . $discount_coupon->fields['coupon_code'] . '</a><br /><br />' : ''), 'fields' => array(array('title' => MODULE_ORDER_TOTAL_COUPON_TEXT_ENTER_CODE, 'field' => zen_draw_input_field('dc_redeem_code', '', 'id="disc-' . $this->code . '" onkeyup="submitFunction(0,0)"'), 'tag' => 'disc-'.$this->code ))); } // eof: stop discount coupon for anyone in a customer group return $selection; }
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: v1.5.5]
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!
Much appreciated Ajeh. I'll give that a whirl.
When you say I should include an exclusion statement, are you referring to the printed/virtual coupon itself or are you refering to code exclusion?
Just a notice such as Discount Coupons not valid with other discounts or something so people do not wonder ...
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: v1.5.5]
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!
Hi, I was wondering if I could somehow apply this idea to a coupon I am preparing for a trade show. I want to offer a coupon to all first time users, but I do not want them to be able to use the coupon if they have made a purchase in the past. Let me say first that I am in NO WAY a good coder, so if you have an idea PLEASE explain it to me as if I were a 4 year old.
Thanks.
You could use this code ... note the line in blue is only needed if not using other IF statements with the same code:
Then you can surround theCode:// bof: stop discount coupon for anyone with an order $allow_discount = true; if ($discount_coupon->fields['coupon_code'] == 'abc123') { global $db; $chk_group = $db->Execute("select orders_id from " . TABLE_ORDERS . " where customers_id = '" . $_SESSION['customer_id'] . "'"); if ($chk_group->RecordCount() > 0) { $allow_discount = false; } else { $allow_discount = true; } } // eof: stop discount coupon for anyone with an order if ($allow_discount) { $selection = array('id' => $this->code, 'module' => $this->title, 'redeem_instructions' => MODULE_ORDER_TOTAL_COUPON_REDEEM_INSTRUCTIONS . ($discount_coupon->fields['coupon_code'] != '' ? MODULE_ORDER_TOTAL_COUPON_REMOVE_INSTRUCTIONS : ''), 'fields' => array(array('title' => ($discount_coupon->fields['coupon_code'] != '' ? MODULE_ORDER_TOTAL_COUPON_TEXT_CURRENT_CODE . '<a href="javascript:couponpopupWindow(\'' . zen_href_link(FILENAME_POPUP_COUPON_HELP, 'cID=' . $_SESSION['cc_id']) . '\')">' . $discount_coupon->fields['coupon_code'] . '</a><br />' : '') . MODULE_ORDER_TOTAL_COUPON_TEXT_ENTER_CODE, 'field' => zen_draw_input_field('dc_redeem_code', '', 'id="disc-' . $this->code . '" onkeyup="submitFunction(0,0)"'), 'tag' => 'disc-'.$this->code ))); } // eof: stop discount coupon for anyone with an order
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: v1.5.5]
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!
Wow, thanks.
OK so, I guess I should edit includes/modules/order_total/ot_coupon.php, and NOT includes/languages/english/modules/order_total/ot_coupon.php.
Also should I add the new code to the top or the bottom of the current code?
I guess I can make the change to the abc123 coupon right in the code you gave me, and not at the coupon manager.
If these guess' are correct I will try it tonight and let you know how it worked.
thanks again.
Actually, if you are going to run both of these IFs together you will need to adjust the code by commenting the line in RED:
Put that code below your other IF code:Code:if ($discount_coupon->fields['coupon_code'] == 'abc123') { global $db; $chk_group = $db->Execute("select orders_id from " . TABLE_ORDERS . " where customers_id = '" . $_SESSION['customer_id'] . "'"); if ($chk_group->RecordCount() > 0) { $allow_discount = false; } else { // $allow_discount = true; } }
Now the new IF won't conflict with the other IF for the customer group ...Code:// bof: stop discount coupon for anyone in a customer group global $db; $chk_group = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where customers_id = '" . $_SESSION['customer_id'] . "'"); if ($chk_group->fields['customers_group_pricing'] > 0) { $allow_discount = false; } else { $allow_discount = true; }
Yes, change the abc123 to your your coupon code you are trying to block if a previous order exists ... and, yes, this is the code file not the language file ...
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: v1.5.5]
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!
Ok,
So I will put both of the two new pieces of code you sent me from your last post in the code file. I will remove the // before the red code and test using the abc123 and see if it works for me.
thanks again and sorry for not being very good with the coding.
Bookmarks