Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1
    Join Date
    Mar 2009
    Posts
    86
    Plugin Contributions
    0

    Default Free shipping AFTER discount codes?

    I have done lots of googling to see if this is something that can be fixed, found things as early as 2006 and the latest being 2012 but no one ever finds a definite answer. I am guessing nothing has come of this?

    I want to have the free shipping applied AFTER a discount code. For example, I offer free shipping worldwide for orders of $40 or more..

    Example order:

    Sub-Total: $43.50
    Free Shipping Options (Free Shipping): $0.00
    Discount Coupon: XXXXXXX : $6.53
    Shipping Insurance: $2.50
    Total: $39.47

    This person just got FREE SHIPPING (Internationally as well and that is expensive) and technically only spent $36.97. It shouldn't allow free shipping because the total after a discount code is NOT $40.

    Is there a way to fix this, has someone created code (or can create code) for this yet?

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

    Default Re: Free shipping AFTER discount codes?

    This was totally NOT fun to do ...

    This is what I finally did in Zen Cart v1.5.1 to make this work, after a zillion attempts to get it working right ...

    Start with the shipping module, this was a total re-write, then I found a better way so do this:
    /includes/modules/shipping/freeoptions.php

    Code:
          // disable only when entire cart is free shipping
          if (zen_get_shipping_enabled($this->code)) {
              $this->enabled = ((MODULE_SHIPPING_FREEOPTIONS_STATUS == 'True') ? true : false);
          }
    
    // bof: manage Free Shipping Options exclude discounts
    if ($_SESSION['free_shipping_options_total'] < MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN && isset($_SESSION['cc_id'])) {
      $this->enabled = false;
    }
    // eof: manage Free Shipping Options exclude discounts
    
          if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FREEOPTIONS_ZONE > 0) ) {

    Then add the code in RED:
    Code:
    // final check for display of Free Options
          if ($this->ck_freeoptions_total or $this->ck_freeoptions_weight or $this->ck_freeoptions_items) {
            $this->enabled = true;
          } else {
            $this->enabled = false;
          }
    
    // bof: manage Free Shipping Options exclude discounts
    //echo '$_SESSION[free_shipping_options_total]: ' . $_SESSION['free_shipping_options_total'] . ' MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN: ' . MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN . ' $_SESSION[cc_id]: ' . $_SESSION['cc_id'] . '<br>';
    if ($_SESSION['free_shipping_options_total'] < MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN && $_SESSION['shipping']['id'] == 'freeoptions_freeoptions' && isset($_SESSION['cc_id'])) {
      $this->enabled = false;
    }
    // eof: manage Free Shipping Options exclude discounts
    
          if ($this->enabled) {

    Next, for the Order Total module, this was also a total re-write, then I found a better way to do this:
    /includes/modules/order_total/ot_coupon.php
    Code:
          $this->output[] = array('title' => $this->title . ': ' . $this->coupon_code . ' :',
                                  'text' => '-' . $currencies->format($od_amount['total']),
                                  'value' => $od_amount['total']);
    
    // bof: manage Free Shipping Options exclude discounts
      $_SESSION['free_shipping_options_total'] = ($order_total['total'] - $od_amount['total']);
    // eof: manage Free Shipping Options exclude discounts

    Now add to the checkout_payment header:
    /includes/modules/pages/checkout_payment/header_php.php
    Code:
    // load all enabled payment modules
    require(DIR_WS_CLASSES . 'payment.php');
    $payment_modules = new payment;
    $flagOnSubmit = sizeof($payment_modules->selection());
    
    // bof: manage Free Shipping Options exclude discounts
    //echo '$_SESSION[free_shipping_options_total]: ' . $_SESSION['free_shipping_options_total'] . ' MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN: ' . MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN . ' $_SESSION[cc_id]: ' . $_SESSION['cc_id'] . '<br>';
    if ($_SESSION['free_shipping_options_total'] < MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN && $_SESSION['shipping']['id'] == 'freeoptions_freeoptions' && isset($_SESSION['cc_id'])) {
      zen_redirect(zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
    }
    // eof: manage Free Shipping Options exclude discounts
    
    require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));

    And finally, the Page file for the checkout_confirmation:
    /includes/modules/pages/checkout_confirmation/header_php.php
    Code:
    if (isset($$_SESSION['payment']->flagDisablePaymentAddressChange)) {
      $flagDisablePaymentAddressChange = $$_SESSION['payment']->flagDisablePaymentAddressChange;
    }
    
    // bof: manage Free Shipping Options exclude discounts
    //echo '$_SESSION[free_shipping_options_total]: ' . $_SESSION['free_shipping_options_total'] . '<br>';
    if ($_SESSION['free_shipping_options_total'] < MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN && $_SESSION['shipping']['id'] == 'freeoptions_freeoptions' && isset($_SESSION['cc_id'])) {
      zen_redirect(zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
    }
    // eof: manage Free Shipping Options exclude discounts
    
    require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
    Now, in theory a customer can come along and pick Free Shipping Options when the Total is >= 40.00 (MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN) and if they then go on and add a Discount Coupon that reduces it to less than 40.00 (MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN) they will be redirected back to the checkout_shipping when they try to go to the checkout_confirmation page ...

    Please test this heavily to ensure that it is working correctly ...
    Last edited by Ajeh; 24 Mar 2014 at 03:22 PM.
    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!

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

    Default Re: Free shipping AFTER discount codes?

    NOTE: these changes are made to files that do not have templates and overrides so be sure to save your originals and these new files as future upgrades will need similar code with possible changes to them ...
    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
    Mar 2009
    Posts
    86
    Plugin Contributions
    0

    Default Re: Free shipping AFTER discount codes?

    Ok, that seems to be working but I have one issue.

    I have free shipping set at $40. I have $135 in my test cart with a coupon code of 50% off. So it should be $67.50.

    It is redirecting me back to shipping again even though they will have met the $40 or more requirement.

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

    Default Re: Free shipping AFTER discount codes?

    Let's try a few changes to the code, and be sure to test this carefully ...

    On the shipping module:
    /includes/modules/shipping/freeoptions.php

    Code:
          // disable only when entire cart is free shipping
          if (zen_get_shipping_enabled($this->code)) {
              $this->enabled = ((MODULE_SHIPPING_FREEOPTIONS_STATUS == 'True') ? true : false);
          }
    
    // bof: manage Free Shipping Options exclude discounts
    //echo '$_SESSION[free_shipping_options_total]: ' . $_SESSION['free_shipping_options_total'] . ' MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN: ' . MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN . ' $_SESSION[cc_id]: ' . $_SESSION['cc_id'] . '<br>';
    if ((isset($_SESSION['free_shipping_options_total'])) && $_SESSION['free_shipping_options_total'] > 0 && $_SESSION['free_shipping_options_total'] < MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN && isset($_SESSION['cc_id'])) {
      $this->enabled = false;
    }
    // eof: manage Free Shipping Options exclude discounts
    
    Code:
    // final check for display of Free Options
          if ($this->ck_freeoptions_total or $this->ck_freeoptions_weight or $this->ck_freeoptions_items) {
            $this->enabled = true;
          } else {
            $this->enabled = false;
          }
    
    // bof: manage Free Shipping Options exclude discounts
    //echo ' Final $_SESSION[free_shipping_options_total]: ' . $_SESSION['free_shipping_options_total'] . ' MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN: ' . MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN . ' $_SESSION[cc_id]: ' . $_SESSION['cc_id'] . '<br>';
    if ($_SESSION['free_shipping_options_total'] < MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN && $_SESSION['free_shipping_options_total'] > 0 && $_SESSION['shipping']['id'] == 'freeoptions_freeoptions' && isset($_SESSION['cc_id'])) {
      $this->enabled = false;
    }
    // eof: manage Free Shipping Options exclude discounts
    
          if ($this->enabled) {
    and in the header file for:
    /includes/modules/pages/checkout_payment/header_php.php

    Code:
    // load all enabled payment modules
    require(DIR_WS_CLASSES . 'payment.php');
    $payment_modules = new payment;
    $flagOnSubmit = sizeof($payment_modules->selection());
    
    // bof: manage Free Shipping Options exclude discounts
    //echo '$_SESSION[free_shipping_options_total]: ' . $_SESSION['free_shipping_options_total'] . ' MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN: ' . MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN . ' $_SESSION[cc_id]: ' . $_SESSION['cc_id'] . '<br>';
    if ($_SESSION['free_shipping_options_total'] > 0 && ($_SESSION['free_shipping_options_total'] < MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN && $_SESSION['shipping']['id'] == 'freeoptions_freeoptions' && isset($_SESSION['cc_id']))) {
      zen_redirect(zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
    }
    // eof: manage Free Shipping Options exclude discounts
    
    require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
    I have not tested this heavily, but try those changes ...
    Last edited by Ajeh; 2 Apr 2014 at 05:11 PM. Reason: Change checkout_payment header
    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
    Mar 2009
    Posts
    86
    Plugin Contributions
    0

    Default Re: Free shipping AFTER discount codes?

    Ok, made those changes and it seems to work but when it redirects to the shipping/delivery information page again, the free shipping options is still there. So if they continue to click free shipping it will take them in circles until they decide to pick another. Is there any way to get it to take the free shipping off the options once it brings them back?

    ETA: Ok, maybe not. Even when I add enough to make it $40 AFTER the coupon code, it's still taking them back to the shipping page over and over again.

  7. #7
    Join Date
    Apr 2014
    Location
    India
    Posts
    5
    Plugin Contributions
    0

    Default Re: Free shipping AFTER discount codes?

    Any luck on this?? Is that code working?
    I have similar requirement. I got Better Together module installed on my cart (www.Maitrini.com), and have free shipping activated on order of more than 299. The problem I am facing is, the free shipping is applied before Better Together discount, which makes the shipping free even the final total goes below 299. Desperately waiting for any solution on this.

  8. #8
    Join Date
    Jan 2012
    Posts
    9
    Plugin Contributions
    0

    Default Re: Free shipping AFTER discount codes?

    anything? it will be highly appreciated if this could work!

  9. #9
    Join Date
    Mar 2009
    Posts
    86
    Plugin Contributions
    0

    Default Re: Free shipping AFTER discount codes?

    I actually paid someone to figure this out for me. I can attaching the php file (with his consent) but I can't figure out how. When I use the attachments it tells me:

    The following errors occurred:
    ot_coupon.php: Invalid File.


    There is only one and it is VERY simple. When someone chooses free shipping and then uses a coupon code, an error message comes up telling them that they don't qualify for free shipping because the total is under $x and tells the customer to go back to shipping and choose a different method or add more to their cart to make it to $x.

    I changed the wording just a bit which is easy, just search for it in the file.

    Attachment 14423

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

    Default Re: Free shipping AFTER discount codes?

    When you Reply, click on the Go Advanced to add the attachment ...
    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!

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Discount coupon with free shipping and free shipping if purchasing additional product
    By webmiss in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 4 May 2012, 02:04 PM
  2. Free Shipping Over £100 problem with discount codes
    By phil_buzz in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 1 Feb 2012, 06:29 PM
  3. Gift Certificate and Discount Codes Do NOt want applied to shipping
    By nolsowski in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 3
    Last Post: 24 Sep 2011, 06:02 PM
  4. Free Shipping to Certain Zip Codes only?
    By SethO in forum Built-in Shipping and Payment Modules
    Replies: 4
    Last Post: 24 Feb 2010, 01:04 PM
  5. Discount Codes & Free Delivery - Help Needed
    By DPM in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 30 Oct 2008, 09:52 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