コード例 #1
0
ファイル: Cart.php プロジェクト: ventsiwad/presta_addons
 public function isCarrierInRange($id_carrier, $id_zone)
 {
     if (version_compare(_PS_VERSION_, "1.4.2.5", "==") || version_compare(_PS_VERSION_, "1.4.3.0", "==")) {
         // fix a bug in Prestashop
         $carrier = new Carrier((int) $id_carrier, Configuration::get('PS_LANG_DEFAULT'));
         $shippingMethod = $carrier->getShippingMethod();
         ###### that is the bug BOF ######
         if (!$carrier->range_behavior) {
             return true;
         }
         ###### that is the bug EOF ######
         if ($shippingMethod == Carrier::SHIPPING_METHOD_FREE) {
             return true;
         }
         if ($shippingMethod == Carrier::SHIPPING_METHOD_WEIGHT && Carrier::checkDeliveryPriceByWeight((int) $id_carrier, $this->getTotalWeight(), $id_zone)) {
             return true;
         }
         if ($shippingMethod == Carrier::SHIPPING_METHOD_PRICE && Carrier::checkDeliveryPriceByPrice((int) $id_carrier, $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING), $id_zone, (int) $this->id_currency)) {
             return true;
         }
     } elseif (version_compare(_PS_VERSION_, "1.4.1.0", "==")) {
         // fix a bug in prestashop
         $carrier = new Carrier((int) $id_carrier, Configuration::get('PS_LANG_DEFAULT'));
         $is_in_zone = false;
         $order_total = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING);
         ###### that is the bug BOF ######
         if (!$carrier->range_behavior) {
             return true;
         }
         ###### that is the bug EOF ######
         if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT and Carrier::checkDeliveryPriceByWeight((int) $id_carrier, $this->getTotalWeight(), $id_zone) or $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE and Carrier::checkDeliveryPriceByPrice((int) $id_carrier, $order_total, $id_zone, (int) $this->id_currency)) {
             $is_in_zone = true;
         }
         unset($carrier);
         return $is_in_zone;
     } else {
         return parent::isCarrierInRange($id_carrier, $id_zone);
     }
     return false;
 }