Zen Cart Logo
Forums / Discounts/Coupons, Gift Certificates, Newsletters, Ads / 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

Views: 1,134

Results 1 to 9 of 9
12 Mar 2014, 8:43 PM
#1
kapsolas avatar

kapsolas

New Zenner

Join Date:
Dec 2012
Posts:
30
Plugin Contributions:
0

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:

14 Mar 2014, 2:07 PM
#2
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

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.

14 Mar 2014, 2:53 PM
#3
ajeh avatar

ajeh

Oba-san

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

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:

[B]// 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
[/B]
        if (!$foundvalid) {
          $this->clear_posts();
        }

see if that works the way you are wanting it to ...

14 Mar 2014, 5:45 PM
#4
kapsolas avatar

kapsolas

New Zenner

Join Date:
Dec 2012
Posts:
30
Plugin Contributions:
0

Re: Q: Is it possible to disable a coupon code based on shipping method

Thanks this worked perfectly!

14 Mar 2014, 5:57 PM
#5
ajeh avatar

ajeh

Oba-san

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

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:

15 Mar 2014, 9:33 AM
#6
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Q: Is it possible to disable a coupon code based on shipping method

Ajeh:

You could add the code in RED to the file:
/includes/modules/order_total/ot_coupon.php

around line 212:

[B]// 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
[/B]
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
15 Mar 2014, 3:08 PM
#7
ajeh avatar

ajeh

Oba-san

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

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:

  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
[B]// bof: do not allow discount coupons on storepickup
    if (substr_count($_SESSION['shipping']['id'], 'storepickup') !=0) {
      $this->clear_posts();
    } else {
[/B]    $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
                       )));
[B]    }
// eof: do not allow discount coupons on storepickup
[/B]    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 ...

16 Mar 2014, 12:22 AM
#8
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Q: Is it possible to disable a coupon code based on shipping method

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:

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
[B]// bof: do not allow discount coupons on storepickup
if (substr_count($_SESSION['shipping']['id'], 'storepickup') !=0) {
$this->clear_posts();
} else {
[/B]
$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
)));
[B] }
// eof: do not allow discount coupons on storepickup
[/B]
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
16 Mar 2014, 1:37 AM
#9
ajeh avatar

ajeh

Oba-san

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

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: