Re: Re: Re: Re: Glad to find this

Joined: 09/24/2007
Juice: 76

Yeah, I understood why you did that as soon as I started writing the Canada Post module. My conern is, as a user, having multiple dimensions fields for every single product is very overkill (as in, a pain in the ass having to enter dimensions 2 or 3 times for every product depending on how many carriers/shipping methods you're using).

Box packing is a non-trivial problem (see http://en.wikipedia.org/wiki/Bin_packing_problem), and so I'm not really sure what you wish to accomplish by leaving it up to each module. Canada Post actually has a box packing algorithm as part of its API, so if you set up boxes in your account, it will tell you how many boxes and what goes in each box. Quickly looking around, the only thing I could find about UPS was that it has volume-based packing - so it will let you fit a golf club into a box half it's length, so long as there is enough volume.

Here's another scenario: PROD1 has a shipping box that is setup to fit 12 items, and PROD2 uses the same box but fits 6 items. If the customer adds 6 PROD1's, and 3 PROD2's, those should fit into one box.. but the system needs to be smart enough to figure that out, instead of sending two half-empty boxes.

What I'm getting at here, is I think that the only real solution is going to be very complex. But let's not lose sight of the goal here: in the end, we're just trying to get an accurate shipping rate to charge the customer. I see all these extra dimensions fields and leaving it up to the individual quote modules to deal with them as a whole lot of effort that doesn't result in accurate rates.

Generally carriers calculate their rates based on two things: number of packages, and billable weight. For most carriers, billable weight is the larger of actual weight and dimensional weight (see: http://www.ups.com/content/us/en/resources/prepare/dim_weight.html).

So I think I do agree with you that it should be up to the quote modules, but it should be implemented slightly differently than it is now. The modules should really try not to add more UI fields to the products themselves, as that increases complexity for the store administrator or whatever poor sap has to type all that info in.

Each quote module should have a "calculation mode" setting, which for UPS would be eg, "Based on weight only", "Based on dimensional weight". Canada Post would add "Based on Canada Post box packing" (the only reason I'm saying leave it up to the modules, instead of doing it in uc_quote).

They'd also have a setting for "dimensional weight markup", a fudge factor that would let you add x lbs/kgs or a percentage of the calculated weight, since in most cases the box is not going to be filled 100%.

There would be another setting for "maximum weight per box", so the number of boxes is calculated based on that.

Getting slightly more complicated, uc_quote could have a place to define standard box sizes for the store, and so once dimensional weight is calculated, the product could call some uc_quote API function that rounds the dimensional weight up into the next nearest box size (based on the box's dim weight of course), and then return an array with the box (or boxes') dimensions. This is just for a shipping estimate though - it's not figuring out what is actually going in each box.

Sorry for being so long winded about this. I'm very much willing to help implement all this, but I would definitely like to come up with a good solution before I (or anyone else) spends a bunch of time coding something.