Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2008
    Posts
    446
    Plugin Contributions
    1

    Default Disable ot_coupon when freeoptions?...

    ZC version 1.5.6c

    I'm in need to trigger an error message and somehow disable ot_coupon from accepting a particular coupon code, or moving forward with the checkout process when said code has been entered. In other words, if client wants free shipping, client cannot use that discount code. If clients wants to use discount code, client cannot get free shipping.

    Is something like this possible?

  2. #2
    Join Date
    Apr 2008
    Posts
    446
    Plugin Contributions
    1

    Default Re: Disable ot_coupon when freeoptions?...

    This always happens to me. I put my head on the pillow for the night (it's almost 4am) and my brain remembers something that could work, so I have to get out of bed and try it.

    For anyone else having a similar issue, add the following to ot_coupon around line 267
    Code:
    
    // bof: disable discount coupons on free shipping
      if (substr_count($_SESSION['shipping']['id'], 'freeoptions') !=0) {
        $foundvalid = false;
      }
    // eof: disable discount coupons on free shipping
    
            if (!$foundvalid) {
              $this->clear_posts();
            }
    This isn't specific for any particular coupon code but for the time being works. What this does is remove the discount coupon or not allow any coupon code to be entered when free shipping is selected. There is an error message that gets triggered, just change it to suit your needs languages>english.php the define is TEXT_INVALID_COUPON_PRODUCT.

    Now I can sleep.

  3. #3
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,697
    Plugin Contributions
    123

    Default Re: Disable ot_coupon when freeoptions?...

    Interesting suggestion. It might also be good to verify that $_SESSION['shipping']['id'] is not empty before checking it just to be sure.
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  4. #4
    Join Date
    Apr 2008
    Posts
    446
    Plugin Contributions
    1

    Default Re: Disable ot_coupon when freeoptions?...

    Quote Originally Posted by swguy View Post
    Interesting suggestion. It might also be good to verify that $_SESSION['shipping']['id'] is not empty before checking it just to be sure.
    I can't take credit for the code. I found something similar a few years back on the forum (I don't remember who posted it) and implemented a version of it on one of my modules. So I remembered this morning I had done something similar to what I needed and reused it. 99% of the time I have no clue what I'm doing and my php knowledge is quite limited, but I manage after a boat load of hours of browsing this wonderful forum

    I use the native zc checkout, which by default requires shipping to be selected before moving forward to add coupons and payments. Wouldn't this sequence imply that $_SESSION['shipping']['id'] is never empty by the time customer enters a coupon code? If not, how do I go about to verify that $_SESSION['shipping']['id'] is not empty?

    Thank you!

  5. #5
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,697
    Plugin Contributions
    123

    Default Re: Disable ot_coupon when freeoptions?...

    It's really just an antibugging step. Strictly speaking in most cases (especially success path) it wouldn't be needed. You would just change

    if (substr_count($_SESSION['shipping']['id'], 'freeoptions') !=0) {

    to

    if (!empty($_SESSION['shipping']['id']) && substr_count($_SESSION['shipping']['id'], 'freeoptions') !=0) {
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  6. #6
    Join Date
    Apr 2008
    Posts
    446
    Plugin Contributions
    1

    Default Re: Disable ot_coupon when freeoptions?...

    Quote Originally Posted by swguy View Post
    It's really just an antibugging step. Strictly speaking in most cases (especially success path) it wouldn't be needed. You would just change

    if (substr_count($_SESSION['shipping']['id'], 'freeoptions') !=0) {

    to

    if (!empty($_SESSION['shipping']['id']) && substr_count($_SESSION['shipping']['id'], 'freeoptions') !=0) {

    Thank you so much! I'll make the change then!
    Happy New Year!

 

 

Similar Threads

  1. v139h If freeoptions criteria=true, how can i disable the other shipping methodes?
    By Angioni in forum Built-in Shipping and Payment Modules
    Replies: 7
    Last Post: 10 Mar 2012, 02:42 PM
  2. How to disable ground services? when using Free Shipping - freeoptions
    By yd29999 in forum Built-in Shipping and Payment Modules
    Replies: 7
    Last Post: 19 Nov 2010, 05:41 AM
  3. How to make perweightunit option disappears when freeoptions is activated?
    By mermaidlisa in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 20 Dec 2009, 10:05 AM
  4. Replies: 3
    Last Post: 7 Aug 2007, 05:32 AM

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