Forums / Bug Reports / [Done v1.3.9] Number of Boxes Bug in perweightunit

[Done v1.3.9] Number of Boxes Bug in perweightunit

Locked

Views: 2,111

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
25 Sep 2009, 5:30 PM
#1
jaywilliams avatar

jaywilliams

New Zenner

Join Date:
Aug 2009
Posts:
6
Plugin Contributions:
0

[Done v1.3.9] Number of Boxes Bug in perweightunit

There is a bug in the perweightunit shipping module, which is in the current version, as well as past versions.

When a customer places an order that is over the "Maximum Package Weight" (Configuration -> Shipping/Packaging), Zen Cart divides the weight between multiple packages. The problem is, the perweightunit shipping module doesn't add the packages together, so it only charges the customer for the first package.

Example:

Shopping Cart Weight: 60lb total
Zen Cart: Split into 2 packages, each being 30lb
perweightunit: [bug] Charge the customer for 1 30lb package (rather than 2 x 30lb)

Solution:

My version of the perweightunit.php file can be found here:
gist.github.com/193690

Here is a diff showing the changes:

diff a/includes/modules/shipping/perweightunit.php b/includes/modules/shipping/perweightunit.php
94c94
<     global $order, $shipping_weight;
---
>     global $order, $shipping_weight, $shipping_num_boxes;
101,102c101,102
<                                                    'cost' => (MODULE_SHIPPING_PERWEIGHTUNIT_COST * $total_weight_units)
<                                                               + MODULE_SHIPPING_PERWEIGHTUNIT_HANDLING)));
---
>                                                    'cost' => ((MODULE_SHIPPING_PERWEIGHTUNIT_COST * $total_weight_units)
>                                                               + MODULE_SHIPPING_PERWEIGHTUNIT_HANDLING)*$shipping_num_boxes)));

Hopefully this helps others who work with perweightunit and large orders.

26 Sep 2009, 3:41 AM
#2
ajeh avatar

ajeh

Oba-san

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

Re: [Done v1.3.9] Number of Boxes Bug in perweightunit

Thanks for the heads up on the problem ... :smile:

However, the fix is close to correct, but is applying a handling fee per box rather than handling per order ...

The function should be changed to:

  function quote($method = '') {
    global $order, $shipping_weight, $shipping_num_boxes;

    $total_weight_units = $shipping_weight;
    $this->quotes = array('id' => $this->code,
                          'module' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_TITLE,
                          'methods' => array(array('id' => $this->code,
                                                   'title' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_WAY,
                                                   'cost' => (MODULE_SHIPPING_PERWEIGHTUNIT_COST * $total_weight_units) * $shipping_num_boxes + MODULE_SHIPPING_PERWEIGHTUNIT_HANDLING)));

    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;
  }

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 Sep 2009, 1:32 AM
#3
jaywilliams avatar

jaywilliams

New Zenner

Join Date:
Aug 2009
Posts:
6
Plugin Contributions:
0

Re: [Done v1.3.9] Number of Boxes Bug in perweightunit

I'm pretty sure the UPS module applies the handling on each package. That's why I set it up that way. But either way, there is still a bug.