Attached patch splits orders in to multiple packages if the weight is over the weight limit. Some items may not be able to be split up, so it also tests each individual line item if its weight or volume exceeds the maximum. Currently this is hardcoded to 22kg for domestic and 20kg for international, not sure if we can load this information dynamically from Australia Post?

Comments

mstrelan created an issue. See original summary.

jcherbert’s picture

That's interesting, I was never concerned about hitting the maximum weight limit as all the products I have worked with hit the maximum volumetric weight limit before reaching the actual weight limit.

I have been working on updating this part of the code also, but to allow the last package in the shipment to be a smaller volume, this is done by assuming the default package size is a maximum package size. So all packages use the maximum package size, except the final package, which will use the remaining volume of the order to calculate the package dimensions.

I held off on creating this patch as I didn't think this would be useful for most people. I think this code needs to be looked at in greater detail. In the meantime, I might try merging your code with mine, and creating a patch.

The Australia Post API doesn't return the maximum allowed weight during a standard parcel calculate call. This would need to be a separate API call prior to the call for the price calculation. I am always concerned with excessive calls, as it can really slow things down.

mstrelan’s picture

My client is shipping tools and parts to build dune buggies, so they're quite heavy. Have you seen https://www.drupal.org/project/packaging? It could help.

jcherbert’s picture

I checked out the packaging module and it does look promising, although at this stage it looks like all of the algorithms are 1D. It looks like very little progress has been made over the last few years. There is an example of its implementation on the USPS module, I will look at doing some work on this but for a 7.x-2.x release of the Australia Post module.

Also, I have looked at implementing your code into a 2D algorithm with the volume based (All In One) code I have been working on. It is working to an extent so far, so I should have a new patch in the next few days.

jcherbert’s picture

I have made some progress with 7.x-2.x-dev in that it integrates with the Packaging module. However Packaging requires this patch and this patch to work with Drupal Commerce. It still doesn't currently allow variable package sizes ( so it will generally over quote ), but I have also created an Auspost 2D packaging strategy so it will create packages limited to both the Australia Post weight limits and default package size defined on the admin page.

Once Packaging (with patches) and 7.x-2.x-dev are installed, you can choose a packaging strategy on the AusPost admin page. This has been optimised for the AusPost All-in-one (last fit 2D)