Results 1 to 10 of 10
  1. #1

    Default Deactivate Flat Rate Shipping module when Free Shipping Options module activates?

    Hi,

    I have two shipping modules enabled - the Flat Rate module and the Free Shipping Options module.

    The Flat Rate module is set up to charge £4.14 for shipping on all orders.

    The Free Shipping Options module is set up to offer free shipping for orders totalling £100 or more.

    If you place items in the cart and the total is less than £100, only the Flat Rate shipping of £4.15 is displayed as a choice to the shopper.

    However, if you place items in the cart and the total is more than £100, both the Flat Rate shipping option and the Free Shipping option is displayed as a choice to the customer.

    Is there a way to switch off the Flat Rate shipping option when the order value is high enough to activate the Free Shipping Options module?

    It’s a minor issue but I think it’s a little confusing to ask a customer with an order value of £100 and above, “Would you like to pay for shipping or not?”

  2. #2
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Deactivate Flat Rate Shipping module when Free Shipping Options module activates?

    What's your sort order for the two shipping methods?

    If the flat rate is displayed lower in the list by sort order, then in the flat rate module, it can inspect available data to determine if the freeoptions module is enabled. Then, if it is, to disable the flat rate module.

    Otherwise, may have to perform the same analysis as the freeoptions module does, but disable the current module if the conditions are met (opposite of what the freeoptions module does).
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3

    Default Re: Deactivate Flat Rate Shipping module when Free Shipping Options module activates?

    To minimise confusion to the customer, I have set the sort order so the Free Shipping option is displayed above / before the Flat Rate option. This way the free option is the first shipping option the customer can see and is selected by default.

    Reversing the sort order only reverses the order in which the shipping options are displayed – both options remain with the only difference being that the Flat Rate option is displayed above / before the Free Shipping option.

  4. #4
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Deactivate Flat Rate Shipping module when Free Shipping Options module activates?

    Quote Originally Posted by Podgeminster View Post
    To minimise confusion to the customer, I have set the sort order so the Free Shipping option is displayed above / before the Flat Rate option. This way the free option is the first shipping option the customer can see and is selected by default.

    Reversing the sort order only reverses the order in which the shipping options are displayed – both options remain with the only difference being that the Flat Rate option is displayed above / before the Free Shipping option.
    So, the sort order will not by itself cause the change that is sought, additional coding is necessary for it all to fit together.

    So, if you have your sort order as first described above (with recommendation that no sort order be set to 0) where the freeoptions module has a lower sort order number than the flat rate module, then modify the flat rate module from:

    Code:
        function __construct() {
          global $order, $db;
    
          $this->code = 'flat';
          $this->title = MODULE_SHIPPING_FLAT_TEXT_TITLE;
          $this->description = MODULE_SHIPPING_FLAT_TEXT_DESCRIPTION;
          $this->sort_order = MODULE_SHIPPING_FLAT_SORT_ORDER;
          $this->icon = '';
          $this->tax_class = MODULE_SHIPPING_FLAT_TAX_CLASS;
          $this->tax_basis = MODULE_SHIPPING_FLAT_TAX_BASIS;
    
          // disable only when entire cart is free shipping
          if (zen_get_shipping_enabled($this->code)) {
            $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false);
          }
    
          if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FLAT_ZONE > 0) ) {
            $check_flag = false;
            $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_FLAT_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
            while (!$check->EOF) {
              if ($check->fields['zone_id'] < 1) {
                $check_flag = true;
                break;
              } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
                $check_flag = true;
                break;
              }
              $check->MoveNext();
            }
    
            if ($check_flag == false) {
              $this->enabled = false;
            }
          }
        }
    to:
    Code:
        function __construct() {
          global $order, $db;
    
          $this->code = 'flat';
          $this->title = MODULE_SHIPPING_FLAT_TEXT_TITLE;
          $this->description = MODULE_SHIPPING_FLAT_TEXT_DESCRIPTION;
          $this->sort_order = MODULE_SHIPPING_FLAT_SORT_ORDER;
          $this->icon = '';
          $this->tax_class = MODULE_SHIPPING_FLAT_TAX_CLASS;
          $this->tax_basis = MODULE_SHIPPING_FLAT_TAX_BASIS;
    
          // disable only when entire cart is free shipping
          if (zen_get_shipping_enabled($this->code)) {
            $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false);
          }
    
          if (IS_ADMIN_FLAG !== true  && $this->enabled == true && isset($GLOBALS['freeoptions']) &&  $GLOBALS['freeoptions']->enabled) {
            $this->enabled = false;
          }
    
           if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FLAT_ZONE > 0) ) {
            $check_flag = false;
            $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_FLAT_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
            while (!$check->EOF) {
              if ($check->fields['zone_id'] < 1) {
                $check_flag = true;
                break;
              } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
                $check_flag = true;
                break;
              }
              $check->MoveNext();
            }
    
            if ($check_flag == false) {
              $this->enabled = false;
            }
          }
        }
    The above code could allows the module to remain accessible if using some form of admin tool that evaluates the code, but on the catalog side, provided that the freeoptions shipping module has a lower sort order than the flat rate module, the flat rate module will be disabled if the freeoptions module is being presented to the customer.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5

    Default Re: Deactivate Flat Rate Shipping module when Free Shipping Options module activates?

    Tried this mod – works perfectly for orders of £100 and over which qualify for free shipping – deactivates the flat rate option when the free option is available.

    However, if the total order value is below £100 and qualifies for the Flat Rate shipping of £4.15 only, neither the free or flat rate options are displayed on the Delivery Information page but the message “Sorry, we are not shipping to your region at this time. Please contact us for alternate arrangements.” is shown.

  6. #6
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Deactivate Flat Rate Shipping module when Free Shipping Options module activates?

    Arrggh, won't show me the content to edit:

    Quote Originally Posted by Podgeminster View Post
    Tried this mod – works perfectly for orders of £100 and over which qualify for free shipping – deactivates the flat rate option when the free option is available.

    However, if the total order value is below £100 and qualifies for the Flat Rate shipping of £4.15 only, neither the free or flat rate options are displayed on the Delivery Information page but the message “Sorry, we are not shipping to your region at this time. Please contact us for alternate arrangements.” is shown.
    Sorry, restore includes/modules/shipping/flat.php to the way it was then modify the following:

    Code:
    // class methods
        function quote($method = '') {
          global $order;
    
          $this->quotes = array('id' => $this->code,
                                'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE,
                                'methods' => array(array('id' => $this->code,
                                                         'title' => MODULE_SHIPPING_FLAT_TEXT_WAY,
                                                         'cost' => MODULE_SHIPPING_FLAT_COST)));
          if ($this->tax_class > 0) {
            $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
          }
    
          if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
    
          return $this->quotes;
        }
    to:
    Code:
    // class methods
        function quote($method = '') {
          global $order;
    
          if (IS_ADMIN_FLAG !== true  && $this->enabled == true && isset($GLOBALS['freeoptions']) &&  $GLOBALS['freeoptions']->enabled) {
            $this->enabled = false;
            return false;
          }
    
          $this->quotes = array('id' => $this->code,
                                'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE,
                                'methods' => array(array('id' => $this->code,
                                                         'title' => MODULE_SHIPPING_FLAT_TEXT_WAY,
                                                         'cost' => MODULE_SHIPPING_FLAT_COST)));
          if ($this->tax_class > 0) {
            $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
          }
    
          if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
    
          return $this->quotes;
        }
    This is needed because really the module can't be determined to need to be disabled until the other module has had an opportunity to determine a quote. Previous would identify that the module was enabled (as set in the admin basically), but hadn't had an opportunity to determine if a quote should be provided at all from it.
    Last edited by mc12345678; 7 Feb 2018 at 09:14 PM.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7

    Default Re: Deactivate Flat Rate Shipping module when Free Shipping Options module activates?

    Quote Originally Posted by mc12345678 View Post
    Arrggh, won't show me the content to edit:

    Quote Originally Posted by Podgeminster View Post
    Tried this mod – works perfectly for orders of £100 and over which qualify for free shipping – deactivates the flat rate option when the free option is available.

    However, if the total order value is below £100 and qualifies for the Flat Rate shipping of £4.15 only, neither the free or flat rate options are displayed on the Delivery Information page but the message “Sorry, we are not shipping to your region at this time. Please contact us for alternate arrangements.” is shown.
    Sorry, restore includes/modules/shipping/flat.php to the way it was then modify the following:

    Code:
    // class methods
        function quote($method = '') {
          global $order;
    
          $this->quotes = array('id' => $this->code,
                                'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE,
                                'methods' => array(array('id' => $this->code,
                                                         'title' => MODULE_SHIPPING_FLAT_TEXT_WAY,
                                                         'cost' => MODULE_SHIPPING_FLAT_COST)));
          if ($this->tax_class > 0) {
            $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
          }
    
          if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
    
          return $this->quotes;
        }
    to:
    Code:
    // class methods
        function quote($method = '') {
          global $order;
    
          if (IS_ADMIN_FLAG !== true  && $this->enabled == true && isset($GLOBALS['freeoptions']) &&  $GLOBALS['freeoptions']->enabled) {
            $this->enabled = false;
            return false;
          }
    
          $this->quotes = array('id' => $this->code,
                                'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE,
                                'methods' => array(array('id' => $this->code,
                                                         'title' => MODULE_SHIPPING_FLAT_TEXT_WAY,
                                                         'cost' => MODULE_SHIPPING_FLAT_COST)));
          if ($this->tax_class > 0) {
            $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
          }
    
          if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
    
          return $this->quotes;
        }
    This is needed because really the module can't be determined to need to be disabled until the other module has had an opportunity to determine a quote. Previous would identify that the module was enabled (as set in the admin basically), but hadn't had an opportunity to determine if a quote should be provided at all from it.
    Tried the amended mod - Still getting the message “Sorry, we are not shipping to your region at this time. Please contact us for alternate arrangements.” Was showing on Step 1 of 3 – Delivery Information” page but is now showing when you click and proceed to “Step 2 of 3 - Payment Information” page.

  8. #8
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Deactivate Flat Rate Shipping module when Free Shipping Options module activates?

    Quote Originally Posted by mc12345678 View Post
    Arrggh, won't show me the content to edit:

    Quote Originally Posted by Podgeminster View Post
    Tried this mod – works perfectly for orders of £100 and over which qualify for free shipping – deactivates the flat rate option when the free option is available.

    However, if the total order value is below £100 and qualifies for the Flat Rate shipping of £4.15 only, neither the free or flat rate options are displayed on the Delivery Information page but the message “Sorry, we are not shipping to your region at this time. Please contact us for alternate arrangements.” is shown.
    Sorry, restore includes/modules/shipping/flat.php to the way it was then modify the following:

    Code:
    // class methods
        function quote($method = '') {
          global $order;
    
          $this->quotes = array('id' => $this->code,
                                'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE,
                                'methods' => array(array('id' => $this->code,
                                                         'title' => MODULE_SHIPPING_FLAT_TEXT_WAY,
                                                         'cost' => MODULE_SHIPPING_FLAT_COST)));
          if ($this->tax_class > 0) {
            $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
          }
    
          if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
    
          return $this->quotes;
        }
    to:
    Code:
    // class methods
        function quote($method = '') {
          global $order;
    
          if (IS_ADMIN_FLAG !== true  && $this->enabled == true && isset($GLOBALS['freeoptions']) &&  $GLOBALS['freeoptions']->enabled) {
            $this->enabled = false;
            return false;
          }
    
          $this->quotes = array('id' => $this->code,
                                'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE,
                                'methods' => array(array('id' => $this->code,
                                                         'title' => MODULE_SHIPPING_FLAT_TEXT_WAY,
                                                         'cost' => MODULE_SHIPPING_FLAT_COST)));
          if ($this->tax_class > 0) {
            $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
          }
    
          if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
    
          return $this->quotes;
        }
    This is needed because really the module can't be determined to need to be disabled until the other module has had an opportunity to determine a quote. Previous would identify that the module was enabled (as set in the admin basically), but hadn't had an opportunity to determine if a quote should be provided at all from it.
    Aggrivating as all to figure out, but finally did. Needed one more factor in the new if statement:
    Changing the base code of:
    Code:
    // class methods
        function quote($method = '') {
          global $order;
    
          $this->quotes = array('id' => $this->code,
                                'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE,
                                'methods' => array(array('id' => $this->code,
                                                         'title' => MODULE_SHIPPING_FLAT_TEXT_WAY,
                                                         'cost' => MODULE_SHIPPING_FLAT_COST)));
          if ($this->tax_class > 0) {
            $this->quotes['tax'] = zen_get_tax_rate($this->tax_class,  $order->delivery['country']['id'], $order->delivery['zone_id']);
          }
    
          if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
    
          return $this->quotes;
        }
    to:
    Code:
    // class methods
        function quote($method = '') {
          global $order;
    
          if (IS_ADMIN_FLAG !== true &&  $this->enabled == true && isset($GLOBALS['freeoptions'])  &&  $GLOBALS['freeoptions']->enabled && $method == '') {
            $this->enabled = false;
            return false;
          }
    
          $this->quotes = array('id' => $this->code,
                                'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE,
                                'methods' => array(array('id' => $this->code,
                                                         'title' => MODULE_SHIPPING_FLAT_TEXT_WAY,
                                                         'cost' => MODULE_SHIPPING_FLAT_COST)));
          if ($this->tax_class > 0) {
            $this->quotes['tax'] = zen_get_tax_rate($this->tax_class,  $order->delivery['country']['id'], $order->delivery['zone_id']);
          }
    
          if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
    
          return $this->quotes;
        }
    This way when a specific method has been identified to obtain a quote, the module will remain active for processing which is basically what was going on when trying to submit the flat rate method.

    Totally tested this and the above worked for all conditions attempted (slightly exceeded the threshold to show freeoptions and flat was disabled, slightly less than the cutoff and of the two only flat showed...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  9. #9

    Default Re: Deactivate Flat Rate Shipping module when Free Shipping Options module activates?

    Excellent!

    Thoroughly tested (so far as possible) and appears to work perfectly.

    Thank you!

  10. #10
    Join Date
    Jan 2013
    Posts
    808
    Plugin Contributions
    0

    Default Re: Deactivate Flat Rate Shipping module when Free Shipping Options module activates?

    i applied this to advanced shipper,
    Code:
    if (IS_ADMIN_FLAG !== true && $this->enabled == true && isset($GLOBALS['freeoptions'])  &&  $GLOBALS['freeoptions']->enabled && $method == '') {
            $this->enabled = false;
            return false;
          }
    it does work, but doesnt let the customer choose another shipping method. i can activate fed ex ground and standard overnight as options to the customer but only the cheapest gets totaled. the standard overnight options shows as checked but cheapest is totaled. if i revert changes or turn off freeoptions than everything works as should.

 

 

Similar Threads

  1. Exclude UK from Flat Rate International Shipping module
    By limelites in forum Built-in Shipping and Payment Modules
    Replies: 4
    Last Post: 29 Mar 2012, 04:01 PM
  2. two shipping options flat rate and free
    By slacker361 in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 7 Aug 2011, 03:22 PM
  3. Cloning the Flat Rate Shipping Module
    By jo_h1971 in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 16 Oct 2009, 12:11 PM
  4. Disable flat rate shipping when free shipping available
    By kazie in forum Built-in Shipping and Payment Modules
    Replies: 7
    Last Post: 6 Oct 2009, 09:59 PM
  5. Flat rate shipping module
    By tammy_kenny in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 25 Jul 2006, 01:07 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