USPS multi-box shipping

I'm evaluating CSCart v2.2.2 and am trying to figure out how to get multi-box shipping working. I am using USPS priority mail (flat rate medium box) and express mail methods with real-time pricing. I have 4 products:



A: 1 lb, can fit 2 per box

B: 1 lb, can fit 2 per box

C: 2 lb, can fit 1 per box

D: 2 lb, cat fit 1 per box



I've tried combinations of product shipping properties (i.e. setting “items in a box” to 2-2 for A and B for example), but I'm not getting any additional charges added when I add multiple products. Instead of starting to randomly test things I wanted to ask if someone knows the settings to use to get what I need.



thanks,

Bill

[size=“3”]So, I took a peek under the hood in shippings/usps.php, and while it is calculating the multi-box package info correctly (and assigning it to $package_info), it does not actually use that information in the XML query sent to the USPS API. It only uses the total weight. So no surprise I guess that it doesn't calculate the multi-box shipping total properly.



I'll try to modify the code so it properly loops over the $package_info array and assemblesthe XML query string from that, then sum the results to get the shipping cost. If it works I'll report back…



Bill[/size]


[quote name='bcomisky' timestamp='1320332715' post='125251']

I'm evaluating CSCart v2.2.2 and am trying to figure out how to get multi-box shipping working. I am using USPS priority mail (flat rate medium box) and express mail methods with real-time pricing. I have 4 products:



A: 1 lb, can fit 2 per box

B: 1 lb, can fit 2 per box

C: 2 lb, can fit 1 per box

D: 2 lb, cat fit 1 per box



I've tried combinations of product shipping properties (i.e. setting “items in a box” to 2-2 for A and B for example), but I'm not getting any additional charges added when I add multiple products. Instead of starting to randomly test things I wanted to ask if someone knows the settings to use to get what I need.



thanks,

Bill

[/quote]

[size=“3”]

ok, that worked! The real time quotes for USPS are now respecting the “items per box” settings in the product shipping properties. I changed the XML string sent to the USPS API to contain a entry for each package with the correct weight and summed the rate info on return.



If this is of interest to anyone else, let me know and I'll post a patch to usps.php.



Bill[/size]


[quote name='bcomisky' timestamp='1320352031' post='125273']

[size=“3”]So, I took a peek under the hood in shippings/usps.php, and while it is calculating the multi-box package info correctly (and assigning it to $package_info), it does not actually use that information in the XML query sent to the USPS API. It only uses the total weight. So no surprise I guess that it doesn't calculate the multi-box shipping total properly.



I'll try to modify the code so it properly loops over the $package_info array and assemblesthe XML query string from that, then sum the results to get the shipping cost. If it works I'll report back…



Bill[/size]

[/quote]

This should be reported as a bug. Now that I think of it, I believe UPS has the same problem. I wouldn't mind taking a look at your changes.

[quote name=‘The Tool’ timestamp=‘1320366934’ post=‘125287’]

This should be reported as a bug. Now that I think of it, I believe UPS has the same problem. I wouldn’t mind taking a look at your changes.

[/quote]



I attached my version of shippings/usps.php and a patch between the original and this file. This is based on version 2.2.2 of CSCart. Things to note:

[list]

[]I didn’t fix international shipping, just domestic, though it shouldn’t be difficult.

[
]I have only tested using Priority Mail and Express Mail.

[]The fix assumes $package[‘weight’] is in pounds, needs to be generalized if this is not always the case.

[
]Use at your own risk!

[/list]

This took me a while to get posted, because my son ended up being born on Friday 11/4!





Update



See post #10 for how this patch also enables the “max weight per box” feature, with a simple template addition to usps.tpl

usps.php

usps-multibox-patch.txt

Wow, thank you Bill! Your fix to the usps shipping solved my problem, we have an item that is bulky and must ship alone, this worked perfectly.

Congratulations on the birth of you son!

Alane

Congrats on the new addition to your family. Any chance you could post a file with the international fixes in place?

[quote name='grayloon' timestamp='1321626558' post='126232']

Congrats on the new addition to your family. Any chance you could post a file with the international fixes in place?

[/quote]



I'll give it a shot when I find a minute, maybe this weekend.

Another problem this patch solves: with the USPS multi-box patch applied it is trivial to get the “maximum weight per box” feature working for USPS. You just need to add the form fields to the usps.tpl template so you can set it in the “Configure” tab in the shippings settings:.



In [your skin directory]/admin/views/shippings/components/services/usps.tpl you can add this to the Domestic shipping section… I put it at line #148 in v2.2.2:


```php


Max weight of box (lbs):


```

Bill