Forums / Built-in Shipping and Payment Modules / Only showing shipping method based on per item or weight amount

Only showing shipping method based on per item or weight amount

Locked

Started by chinook on 18 May 2010, 8:10 PM · Views: 3,672

Results 1 to 11 of 11
This thread is locked. New replies are disabled.
18 May 2010, 8:10 PM
#1
chinook avatar

chinook

New Zenner

Join Date:
May 2010
Posts:
8
Plugin Contributions:
0

Only showing shipping method based on per item or weight amount

I would like the flat rate or table to only show in shipping options if the item is 5lbs or less. Flat rate is there always but if it's more then 5lbs I don't want them selecting that option. It's basically the same for table but I can show them the rate upto 5lbs and if it's over that then it show a rate of 0.00

Basically I need a if this weight or less then this amount otherwise don't show it.

:wacko:

Is this possible???

Thank you!

20 May 2010, 2:28 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: Only showing shipping method based on per item or weight amount

You can customize the flat.php shipping module with:

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

// bof: turn off for more than 5 lbs
global $cart;
$chk_item_weight = $_SESSION['cart']->show_weight();
if ($chk_item_weight > 5) {
$this->enabled = false;
}
// eof: turn off for more than 5 lbs

if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FLAT_ZONE > 0) ) {

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!

20 May 2010, 2:50 PM
#3
chinook avatar

chinook

New Zenner

Join Date:
May 2010
Posts:
8
Plugin Contributions:
0

Re: Only showing shipping method based on per item or weight amount

Ok let me rephrase this post as this is more of what I am trying to do and makes a little more sense so maybe someone can help me.

Is there a way to only show the flat rate shipping method if a customer has <=5 products ordered? If it's >5 products I don't want the flat rate shipping method option to show.

Thanks Again!!

20 May 2010, 2:52 PM
#4
chinook avatar

chinook

New Zenner

Join Date:
May 2010
Posts:
8
Plugin Contributions:
0

Re: Only showing shipping method based on per item or weight amount

Thanks Ajeh.... how can I code it for product instead of weight.

I really appreciate your help.

20 May 2010, 5:19 PM
#5
ajeh avatar

ajeh

Oba-san

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

Re: Only showing shipping method based on per item or weight amount

Use another function from the shopping_cart.php class file for:
count_contents()

instead of the:
show_weight()

See if that helps ... :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!

21 May 2010, 8:02 PM
#6
chinook avatar

chinook

New Zenner

Join Date:
May 2010
Posts:
8
Plugin Contributions:
0

Re: Only showing shipping method based on per item or weight amount

Hi Ajeh

I used the code you provided with the weight and everything works fine on the cart side, and seemed fine yesterday in admin but today in admin under shipping it won't come up and I get this error

Fatal error: Call to a member function show_weight() on a non-object in includes/modules/shipping/flat.php

Hope you can help.
Thank you!!

21 May 2010, 10:09 PM
#7
chinook avatar

chinook

New Zenner

Join Date:
May 2010
Posts:
8
Plugin Contributions:
0

Re: Only showing shipping method based on per item or weight amount

Thanks..... but I figured it out on my own. :clap:
Once again thanks for all your help here....as well as on reading previous threads!!!

22 May 2010, 9:28 AM
#8
ajeh avatar

ajeh

Oba-san

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

Re: Only showing shipping method based on per item or weight amount

Thanks for the update that you have this working now ... :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!

27 May 2010, 11:54 PM
#9
bobthemolder avatar

bobthemolder

Zen Follower

Join Date:
Nov 2008
Posts:
164
Plugin Contributions:
0

Re: Only showing shipping method based on per item or weight amount

chinook:

Hi Ajeh

I used the code you provided with the weight and everything works fine on the cart side, and seemed fine yesterday in admin but today in admin under shipping it won't come up and I get this error

Fatal error: Call to a member function show_weight() on a non-object in includes/modules/shipping/flat.php

Hope you can help.
Thank you!!

It would help if you posted your solution, I'm having this problem as well (mind you, I didn't modify any code).

29 May 2010, 7:56 PM
#10
bmarigoni avatar

bmarigoni

New Zenner

Join Date:
May 2010
Posts:
1
Plugin Contributions:
0

Re: Only showing shipping method based on per item or weight amount

I edited the code for the flat rate module, as well as the UPS module. Now the flat rate displays up to 1 pound, and UPS does not show, after 1 lb has been reached, UPS module kicks in and the flat rate module goes away! PERFECT! I did create a problem though.. Now in the admin area, under MODULES>SHIPPING I get a screen that says SHIPPING MODULES, and there are no modules listed. If I reverse the code and use the default code, I get my shipping modules listed again. Any suggestions? V1.3.9a - but to be clear, I did accomplish what I was trying to do, I just screwed up something else in the process.

30 May 2010, 8:54 AM
#11
ajeh avatar

ajeh

Oba-san

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

Re: Only showing shipping method based on per item or weight amount

Most likely you are using an IF statement to test the cart values ...

You cannot address cart values in the admin as there isn't a cart ...

If you had something like:

// bof: turn off for more than 5 lbs
global $cart;
$chk_item_weight = $_SESSION['cart']->show_weight();
if ($chk_item_weight > 5) {
$this->enabled = false;
}
// eof: turn off for more than 5 lbs

You need to test are you in the Admin with the:
IS_ADMIN_FLAG

// bof: turn off for more than 5 lbs
if (!IS_ADMIN_FLAG) {
global $cart;
$chk_item_weight = $_SESSION['cart']->show_weight();
if ($chk_item_weight > 5) {
$this->enabled = false;
}
}
// eof: turn off for more than 5 lbs

Or, if the IF itself is calling the cart function you can add to it:

if (!IS_ADMIN_FLAG && $_SESSION['cart']->show_weight() >5) {

the idea being that the cart function never gets run in 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!