Forums / Built-in Shipping and Payment Modules / unable to disable flat rate with maximum weight

unable to disable flat rate with maximum weight

Locked

Views: 1,576

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

diy_brewing_company

New Zenner

Join Date:
Jul 2008
Posts:
8
Plugin Contributions:
0

unable to disable flat rate with maximum weight

I have been trying to disable the flat rate shipping module when the weight is over 2 lbs
Here is my code

class flat {
var $code, $title, $description, $icon, $enabled;

// class constructor
function flat() {
global $order, $db , $shipping_weight ;

  $this->code = 'flat';
  $this->title = MODULE_SHIPPING_FLAT_TEXT_TITLE;
  $this->description = MODULE_SHIPPING_FLAT_TEXT_DESCRIPTION;
  $this->sort_order = MODULE_SHIPPING_FLAT_SORT_ORDER;
  $this->icon = '';
  $this->tax_class = MODULE_SHIPPING_FLAT_TAX_CLASS;
  $this->tax_basis = MODULE_SHIPPING_FLAT_TAX_BASIS;

// maximum Shipping Weight: If the shipping weight more than 2lb disable the module
if ($shipping_weight < 2) {
$this->enabled = false;
}

6 Dec 2008, 11:24 PM
#2
kobra avatar

kobra

Black Belt

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

Re: unable to disable flat rate with maximum weight

What is this code yeilding?
What file are you hacking it into?
What version of ZC are you working with?
What ver of php?
What version of mysql?

Zen-Venom Get Bitten

7 Dec 2008, 5:58 PM
#3
ajeh avatar

ajeh

Oba-san

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

Re: unable to disable flat rate with maximum weight

You said you do NOT want Flat Rate flat when shipping weight is > 2 ...

But, your code has this written backwards:

// maximum Shipping Weight: If the shipping weight more than 2lb disable the module
if ($shipping_weight [B]<[/B] 2) {
$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!

8 Dec 2008, 3:49 AM
#4
diy_brewing_company avatar

diy_brewing_company

New Zenner

Join Date:
Jul 2008
Posts:
8
Plugin Contributions:
0

Re: unable to disable flat rate with maximum weight

Hey Kobra
This is the flat rate module. I am using version 1.3.8. I have the newest php and mysql.

The code is not deactivating it for any shipping weight. I have changed it to >2 and the same issues are coming up.
I thought this was the correct code. I am wondering if I calling for the wrong weight? I have tried $total_weight and $shipping_weight.
Thanks

8 Dec 2008, 4:32 AM
#5
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,672
Plugin Contributions:
0

Re: unable to disable flat rate with maximum weight

What are you doing when the weight is over 2 pounds?

Please do not PM for support issues: a private solution doesn't benefit the community.

Be careful with unsolicited advice via email or PM - Make sure the person you are talking to is a reliable source.

8 Dec 2008, 5:26 AM
#6
kobra avatar

kobra

Black Belt

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

Re: unable to disable flat rate with maximum weight

Depending upon the answer you have to Kim's question - - You might use the table rate module and set your table

Shipping Table
2:Your_rate,10000:0.00 or???

Table Method
weight

Zen-Venom Get Bitten

8 Dec 2008, 4:06 PM
#7
diy_brewing_company avatar

diy_brewing_company

New Zenner

Join Date:
Jul 2008
Posts:
8
Plugin Contributions:
0

Re: unable to disable flat rate with maximum weight

When it goes over 2 pounds it is done by UPS rates only. The UPS rates are always displayed but I don't want the flat rate displayed when under 2 lbs

8 Dec 2008, 5:57 PM
#8
ajeh avatar

ajeh

Oba-san

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

Re: unable to disable flat rate with maximum weight

To be safe and ensure that you have accounted for the Tare Rate, just change the function quote to read:

// class methods
    function quote($method = '') {
      global $order;

// don't show when weight < 2
      $this->quote = array();
      $check_order_weight = round($_SESSION['cart']->show_weight(),9);
      if ($check_order_weight < 2) {
        $this->enabled = false;
      }

      if ($this->enabled) {
        $this->quotes = array('id' => $this->code,
                              'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE,
                              'methods' => array(array('id' => $this->code,
                                                       'title' => MODULE_SHIPPING_FLAT_TEXT_WAY,
                                                       'cost' => MODULE_SHIPPING_FLAT_COST)));
        if ($this->tax_class > 0) {
          $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
        }

        if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
      }
      return $this->quotes;
    }

If you do not want to use the Tare rate as part of this, then customize the code in the function flat and just before the closing bracket of the function add:

// don't show when weight < 2
      global $shipping_weight;
      $check_order_weight = $shipping_weight;
      if ($check_order_weight < 2) {
        $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!