Skip to content

Instantly share code, notes, and snippets.

@dtbaker
Last active December 16, 2015 04:29
Show Gist options
  • Save dtbaker/5377796 to your computer and use it in GitHub Desktop.
Save dtbaker/5377796 to your computer and use it in GitHub Desktop.
working out if a product fits within the max dimensions for a "letter" delivery
// work out if we're doing a letter or parcel delivery
// Letter max is 26cm x 36cm x 2cm / 0.5kg
// everything larger will be parcel.
$max_dimensions = array(2,26,36);
if($calculate_product['weight']<=0.5){
$product_dimensions = array($calculate_product['length'],$calculate_product['width'],$calculate_product['height']);
sort($product_dimensions);
$is_letter = (
$product_dimensions[0]<=$max_dimensions[0] &&
$product_dimensions[1]<=$max_dimensions[1] &&
$product_dimensions[2]<=$max_dimensions[2]
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment