Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,267
    Plugin Contributions
    3

    Default Disable Flat Rate Shipping When Total Items in Cart >= 5

    I need a PHP snippet to add to module file flat.php in order to disable the module when the total number of items in the cart is equal to, or greater than 5.

    Ajeh... where are you?
    20 years a Zencart User

  2. #2
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,755
    Plugin Contributions
    9

    Default Re: Disable Flat Rate Shipping When Total Items in Cart >= 5

    You are probably better at php than I

    This was for a check in the USPS module but for flat should be similar

    http://www.zen-cart.com/forum/showthread.php?t=165331

  3. #3
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,267
    Plugin Contributions
    3

    Default Re: Disable Flat Rate Shipping When Total Items in Cart >= 5

    Thanks Kobra... That provided some pointers.

    I am trying the following (in flat.php - module file)

    PHP Code:
          // 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 == false && $_SESSION['cart']->count_contents() > 5) {
      
    $this->enabled false;
    } else {
      
    $this->enabled true;

    ... but it is not disabling the module when there are more than 5 items in the cart...

    Any php gurus out there who can spot my errors?
    20 years a Zencart User

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

    Default Re: Disable Flat Rate Shipping When Total Items in Cart >= 5

    I use the same code and it shows for Item count <= 5 and turns off for Item count > 5 ...
    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!]
    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!

  5. #5
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,267
    Plugin Contributions
    3

    Default Re: Disable Flat Rate Shipping When Total Items in Cart >= 5

    Thanks Linda

    It DOES work (if you type it in correctly ).

    I made a small error using < instead of >.
    20 years a Zencart User

  6. #6
    Join Date
    Jan 2004
    Location
    N of San Antonio TX
    Posts
    9,701
    Plugin Contributions
    11

    Default Re: Disable Flat Rate Shipping When Total Items in Cart >= 5

    So.... Did that make it less of an error?
    A little help with colors.
    myZenCartHost.com - Zen Cart Certified, PCI Compatible Hosting by JEANDRET
    Free SSL & Domain with semi-annual and longer hosting. Updating 1.5.2 and Up.

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

    Default Re: Disable Flat Rate Shipping When Total Items in Cart >= 5

    less of an error ... *snicker* ... glad you have this working now ...
    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!]
    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
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,267
    Plugin Contributions
    3

    Default Re: Disable Flat Rate Shipping When Total Items in Cart >= 5

    Thanks for the help, everyone (including a host of people on other threads which go back some years!).

    For those of you who are interested - and who may have similar situations regarding "unconventional" shipping, the above code was needed to disable the flat rate module, when sufficient items were in the cart, at which point FREE SHIPPING applies.

    My client charges a flat delivery rate for up to 4 items. They also wanted an ALERT to appear during the checkout process, and on the shipping estimator, which appears when there are LESS than 5 items in the cart.

    This alert advises the shopper that FREE shipping will apply if at least 5 items are bought, and invites them to continue shopping.

    Now, the alert is also conditional. If there are 5 or more items, then the alert must not display.

    And of course, if there are 5 or more items, the flat rate module must disappear, and a free shipping module must appear.

    It can all be viewed at www.planscapedirect.co.uk and you don't need to go as far as registering as a customer - just pop some items into the cart and check out shipping estimator. Toggle with a total cart of less than 5 items, and then more than 5 items.

    If anyone is looking to do something similar, join this thread and I'll see if I can help.
    20 years a Zencart User

 

 

Similar Threads

  1. v154 Remove FLAT Rate Shipping when cart value is over
    By tilenk in forum Basic Configuration
    Replies: 3
    Last Post: 17 Mar 2016, 02:48 AM
  2. Disable FLAT RATE ENVELOPE on one product (shipping estimator)
    By sportbiker in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 12 Apr 2010, 12:41 AM
  3. 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
  4. Flat Rate shipping challenge - need a separate rate for a few heavier items
    By Nigel Lew in forum Built-in Shipping and Payment Modules
    Replies: 9
    Last Post: 27 Jun 2008, 10:07 PM
  5. Shipping Question: by order total & flat rate
    By ssolis5788 in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 8 Apr 2007, 12:20 AM

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