Forums / Built-in Shipping and Payment Modules / Flat rate or similar module to only display when over a certain weight?

Flat rate or similar module to only display when over a certain weight?

Locked

Views: 1,425

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
1 Dec 2008, 1:11 PM
#1
sam_m avatar

sam_m

New Zenner

Join Date:
Nov 2007
Posts:
71
Plugin Contributions:
0

Flat rate or similar module to only display when over a certain weight?

Hello,

This is driving me crazy, and im sure its more simple than im finding it. I want to setup a shipping module so say for example the total weight is 2kg or more, It will then kick in with that module (or flat rate), but obviously anything under 2kg wont show the module at all?

I think ive spent too much time with the shipping and for some reason this has got me confused

Any help would be great
thank you
Sam

1 Dec 2008, 1:28 PM
#2
sam_m avatar

sam_m

New Zenner

Join Date:
Nov 2007
Posts:
71
Plugin Contributions:
0

Re: Flat rate or similar module to only display when over a certain weight?

Or to rephrase it, use weight as a minimum order value instead of price

Thanks
Sam

1 Dec 2008, 4:56 PM
#3
ajeh avatar

ajeh

Oba-san

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

Re: Flat rate or similar module to only display when over a certain weight?

You would need to customize the Flat Rate flat shipping module by cloning it for your heavier orders ...

Then, you can customize it further to only show when the weight is >= 2 ...

This can be done by controlling the $this->enabled on the shipping modules and when set to false, they do not show, and when set to true, then the do show ...

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!

1 Dec 2008, 5:09 PM
#4
fairestcape avatar

fairestcape

Totally Zenned

Join Date:
Mar 2008
Location:
Cape Town & London (depends on the season)
Posts:
2,957
Plugin Contributions:
0

Re: Flat rate or similar module to only display when over a certain weight?

To illustrate Ajeh's point, I have a clone of zonetables shipping module, and modified the code as follows to govern the display of the module (shipping option) based on the weight:-

  function zonetable() {
    global $order, $db, $total_weight;

    // CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED
    $this->num_zones = 6;

    $this->code = 'zonetable';
    $this->title = MODULE_SHIPPING_ZONETABLE_TEXT_TITLE;
    $this->description = MODULE_SHIPPING_ZONETABLE_TEXT_DESCRIPTION;
    $this->sort_order = MODULE_SHIPPING_ZONETABLE_SORT_ORDER;
    $this->icon = '';
    $this->tax_class = MODULE_SHIPPING_ZONETABLE_TAX_CLASS;
    $this->tax_basis = MODULE_SHIPPING_ZONETABLE_TAX_BASIS;
    // disable only when entire cart is free shipping
    if (zen_get_shipping_enabled($this->code)) {
      $this->enabled = ((MODULE_SHIPPING_ZONETABLE_STATUS == 'True') ? true : false);
    }
    // Minimum Shipping Weight: If the shipping weight less than 2Kg disable the module
    if ($total_weight < 2) {
      $this->enabled = false;
  	}

(parts I added are in red).

PS: a SECOND clone I made (zonetablestwo) reverses the limiter and shows another module when the weight is MORE THAN 2kg.

Simply reverse:

// Minimum Shipping Weight: If the shipping weight more than 2Kg disable the module
    if ($total_weight > 2) {
      $this->enabled = false;
  	}
1 Dec 2008, 5:43 PM
#5
ajeh avatar

ajeh

Oba-san

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

Re: Flat rate or similar module to only display when over a certain weight?

Be aware that the $total_weight does not include the Tare Rate ... and you could end up with different results on checkout_shipping ...

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!

1 Dec 2008, 5:51 PM
#6
fairestcape avatar

fairestcape

Totally Zenned

Join Date:
Mar 2008
Location:
Cape Town &amp; London (depends on the season)
Posts:
2,957
Plugin Contributions:
0

Re: Flat rate or similar module to only display when over a certain weight?

WELL SPOTTED LINDA!

Yes... my TARES are set to "null" as my actual product weights factor in the weight value of packaging.

(By the way... is there a way to INCLUDE tare in my code example?)

1 Dec 2008, 6:48 PM
#7
ajeh avatar

ajeh

Oba-san

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

Re: Flat rate or similar module to only display when over a certain weight?

The problem is, it knows the total weight plus the tare in the quote of the shipping module, example:

  function quote($method = '') {
    global $order, $shipping_weight;
echo 'QUOTE: ' . $shipping_weight . '<br>';

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!

2 Dec 2008, 11:36 PM
#8
sam_m avatar

sam_m

New Zenner

Join Date:
Nov 2007
Posts:
71
Plugin Contributions:
0

Re: Flat rate or similar module to only display when over a certain weight?

thanks guys, will have a bash at this ASAP :)