I have made some modifications to a third party shipping module (Webshopapps_UsaShipping, fedex) so that I can base shipping costs on the origin of which warehouse will ship the item. This is working fine.

My issue is when I put two items in the cart and change the quantity of at least one of the items to more than one, collectRates gets called twice and the results of are added together.

For instance, if my cart contains:

SKU1 , Qnty 2, 56lbs each
SKU2 , Qnty 1, 45lbs each

CollectRates is called twice. Each time it's called, the collectRates comes up with the same exact rates, but the results of each call are added together doubling the shipping. I have dumped and compared the $request that is sent to collectRates each time. I have also compared the response returned by collectRates when there is only one of each item in the cart. The returned objects are exactly the same except for the costs (I was trying to rule out maybe not passing something back to indicate the shipment is complete).

But the request sent to CollectRates is different the first and second time it's called: The first request has

[package_weight] => 101 

The second one has

[package_weight] => 56

It split it into two shipments, one of each item, and the balance of the qnty 2 item.

I am not understanding this because the rest of the request is correct, and has both cart items listed with proper quantities and individual weights.

Any idea why the system would split the shipment before sending it to collectRates (the shipping module already splits the shipment as per configuration rules)?

I'm also wondering if it's caused by another extension or default behavior of the magento system. I've googled and haven't found anything that indicated the stock magento install would call collectRates more than once for the same cart contents. (Yes it can be called more than once when calculating cart totals, but it's only called once for the cart contents, not split like we are seeing here.)

1 Answer 1


Apparently there is a conflict between the core magento shipping code and the modified shipusa extension.

In Mage_Shipping_Model_Shipping, magento combines items up to $maxWeight for the carrier (in the carrier config section of admin). So in my case, 56 + 56 + 45 is 157 lbs, which is over the 150 lbs set for the max fedex package weight. Magento calls _makePieces which combines the order into two boxes, 101 and 56lbs. The shipusa extension already splits the shipments (as it also handles multi-box shipments and alternative pack methods) so I'm not sure how they got around this, but something I did must have broke something in the original extension code.

I the easiest fix for now is to increase the max package weight to something very high so _makePieces combines the shipment into one "box" where my collectRates will split it up based on the products.

  • 1
    Please mark this as accepted.
    – Marius
    Commented Nov 10, 2014 at 8:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.