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?![]()
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
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
Thanks Kobra... That provided some pointers.
I am trying the following (in flat.php - module file)
... but it is not disabling the module when there are more than 5 items in the cart...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;
}
Any php gurus out there who can spot my errors?
20 years a Zencart User
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!
Thanks Linda
It DOES work (if you type it in correctly).
I made a small error using < instead of >.
20 years a Zencart User
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.
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!
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