Q: Is it possible to disable a coupon code based on shipping method
Q: Is it possible to disable a coupon code based on shipping method.
We have enabled store pickup but would not like customers who pickup in store with online prices to be able to use a coupon code.
Is there a way to disable this?
Thanks
:smile:
Re: Q: Is it possible to disable a coupon code based on shipping method
The discount coupon module would need a code to see the shipping selection the customer has chosen in the cart.
Re: Q: Is it possible to disable a coupon code based on shipping method
You could add the code in RED to the file:
/includes/modules/order_total/ot_coupon.php
around line 212:
Code:
// bof: do not allow discount coupons on storepickup
if (substr_count($_SESSION['shipping']['id'], 'storepickup') !=0) {
$foundvalid = false;
}
// eof: do not allow discount coupons on storepickup
if (!$foundvalid) {
$this->clear_posts();
}
see if that works the way you are wanting it to ...
Re: Q: Is it possible to disable a coupon code based on shipping method
Thanks this worked perfectly!
Re: Q: Is it possible to disable a coupon code based on shipping method
Thanks for the update that this was able to work for you ... :smile:
Re: Q: Is it possible to disable a coupon code based on shipping method
Quote:
Originally Posted by
Ajeh
You could add the code in
RED to the file:
/includes/modules/order_total/ot_coupon.php
around line 212:
Code:
// bof: do not allow discount coupons on storepickup
if (substr_count($_SESSION['shipping']['id'], 'storepickup') !=0) {
$foundvalid = false;
}
// eof: do not allow discount coupons on storepickup
if (!$foundvalid) {
$this->clear_posts();
}
see if that works the way you are wanting it to ...
Ajeh, I have played with your suggested code and tried a few varieties.
No doubt, your hack disables coupons for Store Pickup - BUT: the customer is getting an error message (as they should) and needs to go through the checkout pages again to complete the order.
IMHO, it would be more 'elegant' to simply not display (= disable) the fieldset on the checkout_payment page where coupon codes may be entered.
IOW: there should be no facility to enter a coupon code if (on the previous page checkout_shipping) Store Pickup was selected as a shipping method.
I looked at includes/modules/pages/checkout_shipping/header_php.php (and the corresponding template file) and then applied a few conditions but only had limited success.
What can you suggest?
Thanks / Frank
Re: Q: Is it possible to disable a coupon code based on shipping method
You will need two parts to the code in case the customer first picks another shipping method ...
So, leave in the code that I first gave you, then add the code in RED:
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: do not allow discount coupons on storepickup
if (substr_count($_SESSION['shipping']['id'], 'storepickup') !=0) {
$this->clear_posts();
} else {
$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: do not allow discount coupons on storepickup
return $selection;
}
This will make the Discount Coupon disappear if the customer first chooses Store Pickup and if they first choose another shipping module then change their mind it will still clear out the Discount Coupon they were trying to use ...
Re: Q: Is it possible to disable a coupon code based on shipping method
Quote:
Originally Posted by
Ajeh
You will need two parts to the code in case the customer first picks another shipping method ...
So, leave in the code that I first gave you, then add the code in
RED:
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: do not allow discount coupons on storepickup
if (substr_count($_SESSION['shipping']['id'], 'storepickup') !=0) {
$this->clear_posts();
} else {
$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: do not allow discount coupons on storepickup
return $selection;
}
This will make the Discount Coupon disappear if the customer first chooses Store Pickup and if they first choose another shipping module then change their mind it will still clear out the Discount Coupon they were trying to use ...
Perfect - thank you
Frank
Re: Q: Is it possible to disable a coupon code based on shipping method
Thanks for the update that this is working for you ... :smile: