If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / Disable Flat Rate Shipping When Total Items in Cart >= 5

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

Started by schoolboy on 8 Jun 2011, 11:59 AM · Views: 796

Results 1 to 8 of 8
8 Jun 2011, 11:59 AM
#1
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

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? :D

20 years a Zencart User

8 Jun 2011, 12:04 PM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

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

Zen-Venom Get Bitten

8 Jun 2011, 10:47 PM
#3
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

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)

      // 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

8 Jun 2011, 11:41 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

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!

8 Jun 2011, 11:48 PM
#5
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

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

Thanks Linda

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

I made a small error using < instead of >.

20 years a Zencart User

9 Jun 2011, 12:18 AM
#6
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,903
Plugin Contributions:
23

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

So.... Did that make it less of an error? :P

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

9 Jun 2011, 12:50 AM
#7
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

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

less of an error ... snicker ... glad you have this working now ... :lamo:

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!

9 Jun 2011, 2:14 AM
#8
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

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 https://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