public function getUSPSRates($id_zone, $is_cart, $cart, $product_weight, $dest_zip, $dest_state, $dest_country, $currency, $product, $id_product_attribute, $qty) { $rates = array(); if (file_exists(dirname(__FILE__) . '/../../usps/classes/RateAvailableServices.php')) { include_once dirname(__FILE__) . '/../../usps/usps.php'; include_once dirname(__FILE__) . '/../../usps/classes/RateAvailableServices.php'; $usps = new USPS(); if ($usps->active) { // Get handling cost (once) $handling = Configuration::get('PS_SHIPPING_HANDLING'); $carriers = $usps->getCarriers($id_zone, $cart, $is_cart, $product); foreach ($carriers as $carrier) { //check if USPS module is new or old if (get_parent_class($usps) == 'PrestoChangeoCarrierModule') { $USPSRate = new USPSRate(); $amount = $USPSRate->getRate($carrier['id_carrier'], $carrier['id_zone'], $is_cart != '' ? $cart->getTotalWeight() : max($product_weight, 0.001), $dest_zip, $dest_state, $dest_country, "", $is_cart != '' ? 0 : $product->getPrice(true, $id_product_attribute, 6, NULL, false, true, $qty), $is_cart != '' ? 0 : $product->id, $is_cart != '' ? 0 : $id_product_attribute, $qty); } else { $amount = getUSPSRate($carrier['id_carrier'], $carrier['id_zone'], $is_cart != '' ? $cart->getTotalWeight() : max($product_weight, 0.001), $dest_zip, $dest_state, $dest_country, "", $is_cart != '' ? 0 : $product->getPrice(true, $id_product_attribute, 6, NULL, false, true, $qty), $is_cart != '' ? 0 : $product->id, $is_cart != '' ? 0 : $id_product_attribute, $qty); } // Add product spercific cost + handling fee if ($amount > 0) { $amount += $this->getExtraShippingCost($carrier, $handling, $is_cart != '' ? $cart->getProducts() : array(), $product, $qty); } // Apply shipping tax if needed if (!Tax::excludeTaxeOption()) { $carrierTax = Tax::getCarrierTaxRate($carrier['id_carrier']); } if (isset($carrierTax) && $amount !== false) { $amount *= 1 + $carrierTax / 100; } $amount = $amount === false ? -1 : Tools::convertPrice($amount, $currency); if ($amount > 0) { $rates[$carrier['name']] = array(Tools::displayPrice($amount, $currency, false), $carrier['id_carrier']); } elseif ($amount !== false && $amount == 0) { $rates[$carrier['name']] = array($usps->l('Free!'), $carrier['id_carrier']); } } } } return $rates; }