Results 1 to 9 of 9
  1. #1
    Join Date
    Dec 2012
    Posts
    30
    Plugin Contributions
    0

    database error 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

  2. #2
    Join Date
    Apr 2007
    Location
    Ontario, Canada
    Posts
    1,731
    Plugin Contributions
    27

    Default 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.
    Twitch.
    https://www.twitchtoo.com Do you work for free? Please donate.
    Twitch Base8 - Obsidian - This, is what's new.

  3. #3
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default 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 ...
    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!

  4. #4
    Join Date
    Dec 2012
    Posts
    30
    Plugin Contributions
    0

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

    Thanks this worked perfectly!

  5. #5
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default 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 ...
    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!

  6. #6
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

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

    Quote Originally Posted by Ajeh View Post
    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
    Last edited by frank18; 15 Mar 2014 at 10:36 AM.

  7. #7
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default 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 ...
    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!

  8. #8
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

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

    Quote Originally Posted by Ajeh View Post
    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

  9. #9
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

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

    Thanks for the update that this is working for you ...
    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!

 

 

Similar Threads

  1. v151 Disable a payment method for a chosen shipping method?
    By chowyungunz in forum Built-in Shipping and Payment Modules
    Replies: 7
    Last Post: 12 Jun 2015, 12:56 PM
  2. v139h Is it possible to disable/hide gift cert, discount coupon etc
    By cabdr1ver in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 5
    Last Post: 29 Feb 2012, 08:14 PM
  3. shipping method based on payment method?
    By psr racing in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 27 Apr 2011, 01:25 PM
  4. Email coupon code based on order history
    By Crunch in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 3
    Last Post: 6 Nov 2009, 05:04 PM
  5. Auto Email to employee after sale based on coupon code?
    By james431987 in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 11 Sep 2009, 12:48 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR