Forums / Built-in Shipping and Payment Modules / Remove a shipping method based on value

Remove a shipping method based on value

Locked

Started by dab on 11 Aug 2009, 8:43 PM · Views: 1,286

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
11 Aug 2009, 8:43 PM
#1
dab avatar

dab

New Zenner

Join Date:
Jan 2007
Location:
UK
Posts:
62
Plugin Contributions:
0

Remove a shipping method based on value

I am currently using ZC 1.3.7 and have 3 methods of shipping - flat rate, next day and overseas.

Is it possible to remove one of the options from the customers choice (the flat rate) if the order is above a certain value.
ie to just offer next day and overseas.

13 Aug 2009, 4:54 AM
#2
ajeh avatar

ajeh

Oba-san

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

Re: Remove a shipping method based on value

Edit the Flat Rate flat shipping module and change:

      // disable only when entire cart is free shipping
      if (zen_get_shipping_enabled($this->code)) {
        $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false);
      }

to read:

      // disable only when entire cart is free shipping
      if (zen_get_shipping_enabled($this->code)) {
        $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false);
      }

      global $cart;
      if (IS_ADMIN_FLAG == false && $_SESSION['cart']->show_total() >= 75.00) {
        $this->enabled = false;
      }

where 75.00 is the amount to turn off the shipping module at ...

The IS_ADMIN_FLAG is used so that the module works on the Admin ...

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!

13 Aug 2009, 8:00 PM
#3
dab avatar

dab

New Zenner

Join Date:
Jan 2007
Location:
UK
Posts:
62
Plugin Contributions:
0

Re: Remove a shipping method based on value

Thank you Linda, that worked perfectly.

13 Aug 2009, 10:55 PM
#4
ajeh avatar

ajeh

Oba-san

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

Re: Remove a shipping method based on value

Thanks for the update that this worked for you ... :smile:

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!

14 Aug 2009, 4:04 PM
#5
ctopher avatar

ctopher

New Zenner

Join Date:
Nov 2006
Posts:
24
Plugin Contributions:
0

Re: Remove a shipping method based on value

You can also disable the flat rate based on weight. Suppose you want to disable flat rate shipping on orders over 5 lbs.

You need to edit
/includes/modules/shipping/flat.php

You would insert this code just below the code that disables the module if entire cart is free shipping.

// disable if the weight is over 5lbs
global $cart;
$shipWeight = $_SESSION['cart']->show_weight();
if (IS_ADMIN_FLAG == false && $shipWeight >= 5.00) {
	$this->enabled = false;
}

It's too bad these modules cannot be changed via overrides. Or can they?

14 Aug 2009, 5:06 PM
#6
ajeh avatar

ajeh

Oba-san

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

Re: Remove a shipping method based on value

There are not overrides for the shipping modules but you can always clone a shipping module ...

NOTE: be sure to test new shipping modules or changes in both the Catalog and Admin to ensure that they run properly ...

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!

22 Sep 2009, 7:50 PM
#7
thenax avatar

thenax

New Zenner

Join Date:
Jun 2009
Posts:
67
Plugin Contributions:
0

Re: Remove a shipping method based on value

and what is the code if I would disable the modules with weight < 5 and total > 50 ?

22 Sep 2009, 10:37 PM
#8
ajeh avatar

ajeh

Oba-san

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

Re: Remove a shipping method based on value

global $cart;
$shipWeight = $_SESSION['cart']->show_weight();
$shipTotal = $_SESSION['cart']->show_total();
if (IS_ADMIN_FLAG == false && ($shipWeight < 5.00 and $shipTotal > 50) {
	$this->enabled = false;
}

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!