The current international package validation is not the correct approach for the the specifications provided by Australia Post.
Australia Post states:
The formula for working out the girth of your overseas parcel is: (width + height) x 2 = girth. When measuring dimensions, the longest side of the parcel is considered the length. Ie, the two shortest sides are used to calculate girth.
The current validation checks several combinations of the sides that include the length. I think the idea being that the user may mix up the L x W x H and so you're checking them all to be safe. The issue with this is that it can lead to falsely preventing a package from being used in the rate calculation.
I think a better approach would be to identify the two shortest sides and use that to calculate the girth as this is what Australia Post specifically states to do.
Below is my suggestion:
src/PostageServices/ServiceSupport.php - function validatePackageSize()
...
else {
// International packages have girth requirements,
// (where girth = ((width + height) * 2)).
// Australia Post considers the longest edge of a parcel to be the length.
$values = [
'height' => $height,
'length' => $length,
'width' => $width,
];
$valueA = $valueB = new Length(9999, LengthUnit::CENTIMETER);
foreach ($values as $key => $value) {
if ($value->compareTo($valueA) < 0) {
$valueB = $valueA;
$valueA = $value;
}
else if ($value->compareTo($valueB) < 0) {
$valueB = $value;
}
}
$girth = $valueA->add($valueB)
->multiply('2');
if ($max['girth']->lessThan($girth)) {
throw new PackageSizeException(
"Package girth ({$girth}, calculated using '{$valueA}cm' and '{$valueB}cm') is greater than the AusPost maximum of '{$max['girth']}'."
);
}
}
...
The current international package validation is not the correct approach for the the specifications provided by Australia Post.
Australia Post states:
https://auspost.com.au/sending/check-sending-guidelines/size-weight-guidelines
The current validation checks several combinations of the sides that include the length. I think the idea being that the user may mix up the L x W x H and so you're checking them all to be safe. The issue with this is that it can lead to falsely preventing a package from being used in the rate calculation.
I think a better approach would be to identify the two shortest sides and use that to calculate the girth as this is what Australia Post specifically states to do.
Below is my suggestion:
src/PostageServices/ServiceSupport.php - function validatePackageSize()