/** * Calculate carrier price by restrictions * * @param array $product Product dimensions array * @param array $rescriction rescriction who need to be apply * @param float $cartPrice Total cart price is for free shipping * @return mix boolean false if price shipping not allowed * float price of shipping */ public static function getRescrictionPrice($product, $rescriction, $cartPrice = 0) { $price = array('regular' => (double) 0, 'additional' => (double) 0); if ($rescriction['free_from_price'] >= 0) { //free shipping is enabled if ($cartPrice >= $rescriction['free_from_price']) { $price['regular'] = (double) 0.0; //Return free shipping return $price; } } if ($product['height'] <= $rescriction['dimensions']['height'] && $product['width'] <= $rescriction['dimensions']['width'] && $product['depth'] <= $rescriction['dimensions']['depth']) { //Package size is small $price['regular'] = (double) $rescriction['base_price']; //Return base shipping price return $price; } else { //Package size is to high if ($rescriction['oversized_price'] == '-1') { //Oversize is not disallowed? return false; //Cannot ship this product } else { //Oversize is allowed if ($rescriction['oversized_price'] >= 0) { //Oversize price is correct? $price = array('regular' => (double) $rescriction['base_price'], 'additional' => (double) ($rescriction['oversized_price'] * $product['quantity'])); return $price; } else { DynamicParcelDistribution::log('getRescrictionPrice -> Oversize price is not correct given: ' . $rescriction['oversized_price']); return false; } } } return false; }