当前位置: 首页>>代码示例>>PHP>>正文


PHP Carrier::getShippingMethod方法代码示例

本文整理汇总了PHP中Carrier::getShippingMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP Carrier::getShippingMethod方法的具体用法?PHP Carrier::getShippingMethod怎么用?PHP Carrier::getShippingMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Carrier的用法示例。


在下文中一共展示了Carrier::getShippingMethod方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isCarrierInRange

 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;
 }
开发者ID:ventsiwad,项目名称:presta_addons,代码行数:40,代码来源:Cart.php

示例2: isCarrierInRange

 /**
  * isCarrierInRange
  *
  * Check if the specified carrier is in range
  *
  * @id_carrier int
  * @id_zone int
  */
 public function isCarrierInRange($id_carrier, $id_zone)
 {
     $carrier = new Carrier((int) $id_carrier, Configuration::get('PS_LANG_DEFAULT'));
     $shipping_method = $carrier->getShippingMethod();
     if (!$carrier->range_behavior) {
         return true;
     }
     if ($shipping_method == Carrier::SHIPPING_METHOD_FREE) {
         return true;
     }
     $check_delivery_price_by_weight = Carrier::checkDeliveryPriceByWeight((int) $id_carrier, $this->getTotalWeight(), $id_zone);
     if ($shipping_method == Carrier::SHIPPING_METHOD_WEIGHT && $check_delivery_price_by_weight) {
         return true;
     }
     $check_delivery_price_by_price = Carrier::checkDeliveryPriceByPrice((int) $id_carrier, $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING), $id_zone, (int) $this->id_currency);
     if ($shipping_method == Carrier::SHIPPING_METHOD_PRICE && $check_delivery_price_by_price) {
         return true;
     }
     return false;
 }
开发者ID:dev-lav,项目名称:htdocs,代码行数:28,代码来源:Cart.php

示例3: generateFlux

 public function generateFlux()
 {
     if (Tools::getValue('token') == '' || Tools::getValue('token') != Configuration::get('SHOPPING_FLUX_TOKEN')) {
         die('Invalid Token');
     }
     $titles = array(0 => 'id_produit', 1 => 'nom_produit', 2 => 'url_produit', 3 => 'url_image', 4 => 'description', 5 => 'description_courte', 6 => 'prix', 7 => 'prix_barre', 8 => 'frais_de_port', 9 => 'delaiLiv', 10 => 'marque', 11 => 'rayon', 12 => 'stock', 13 => 'qte_stock', 14 => 'EAN', 15 => 'poids', 16 => 'ecotaxe', 17 => 'TVA', 18 => 'Reference constructeur', 19 => 'Reference fournisseur');
     echo implode("|", $titles) . "\r\n";
     //For Shipping
     $configuration = Configuration::getMultiple(array('PS_TAX_ADDRESS_TYPE', 'PS_CARRIER_DEFAULT', 'PS_COUNTRY_DEFAULT', 'PS_LANG_DEFAULT', 'PS_SHIPPING_FREE_PRICE', 'PS_SHIPPING_HANDLING', 'PS_SHIPPING_METHOD', 'PS_SHIPPING_FREE_WEIGHT'));
     $products = Product::getSimpleProducts($configuration['PS_LANG_DEFAULT']);
     $defaultCountry = new Country($configuration['PS_COUNTRY_DEFAULT'], Configuration::get('PS_LANG_DEFAULT'));
     $id_zone = (int) $defaultCountry->id_zone;
     $carrier = new Carrier((int) $configuration['PS_CARRIER_DEFAULT']);
     $carrierTax = Tax::getCarrierTaxRate((int) $carrier->id, (int) $this->{$configuration['PS_TAX_ADDRESS_TYPE']});
     foreach ($products as $key => $produit) {
         $product = new Product((int) $produit['id_product'], true, $configuration['PS_LANG_DEFAULT']);
         //For links
         $link = new Link();
         //For images
         $cover = $product->getCover($product->id);
         $ids = $product->id . '-' . $cover['id_image'];
         //For shipping
         if ($product->getPrice(true, NULL, 2, NULL, false, true, 1) >= (double) $configuration['PS_SHIPPING_FREE_PRICE'] and (double) $configuration['PS_SHIPPING_FREE_PRICE'] > 0) {
             $shipping = 0;
         } elseif (isset($configuration['PS_SHIPPING_FREE_WEIGHT']) and $product->weight >= (double) $configuration['PS_SHIPPING_FREE_WEIGHT'] and (double) $configuration['PS_SHIPPING_FREE_WEIGHT'] > 0) {
             $shipping = 0;
         } else {
             if (isset($configuration['PS_SHIPPING_HANDLING']) and $carrier->shipping_handling) {
                 $shipping = (double) $configuration['PS_SHIPPING_HANDLING'];
             }
             if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) {
                 $shipping += $carrier->getDeliveryPriceByWeight($product->weight, $id_zone);
             } else {
                 $shipping += $carrier->getDeliveryPriceByPrice($product->getPrice(true, NULL, 2, NULL, false, true, 1), $id_zone);
             }
             $shipping *= 1 + $carrierTax / 100;
             $shipping = (double) Tools::ps_round((double) $shipping, 2);
         }
         $data = array();
         $data[0] = $product->id;
         $data[1] = $product->name;
         $data[2] = $link->getProductLink($product);
         $data[3] = $link->getImageLink($product->link_rewrite, $ids, 'large');
         $data[4] = $product->description;
         $data[5] = $product->description_short;
         $data[6] = $product->getPrice(true, NULL, 2, NULL, false, true, 1);
         $data[7] = $product->getPrice(true, NULL, 2, NULL, false, false, 1);
         $data[8] = $shipping;
         $data[9] = $carrier->delay[2];
         $data[10] = $product->manufacturer_name;
         $data[11] = $product->category;
         $data[12] = $product->quantity > 0 ? 'oui' : 'non';
         $data[13] = $product->quantity;
         $data[14] = $product->ean13;
         $data[15] = $product->weight;
         $data[16] = $product->ecotax;
         $data[17] = $product->tax_rate;
         $data[18] = $product->reference;
         $data[19] = $product->supplier_reference;
         foreach ($data as $key => $value) {
             $data[$key] = $this->clean($value);
         }
         echo implode("|", $data) . "\r\n";
     }
 }
开发者ID:ricardo-rdfs,项目名称:Portal-BIP,代码行数:65,代码来源:shoppingfluxexport.php

示例4: getOrderShippingCostPerSellerCarrier

 public function getOrderShippingCostPerSellerCarrier($id_seller, $use_tax, $id_zone, $id_carrier, $carrier_amount, $carrier_weight)
 {
     $shipping_cost = 0;
     $carrier = new Carrier($id_carrier, $this->id_lang);
     if ($carrier->is_free == 1) {
         return 0;
     }
     if ($use_tax and !Tax::excludeTaxeOption()) {
         $carrierTax = Tax::getCarrierTaxRate((int) $carrier->id, (int) $this->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
     }
     $configuration = Configuration::getMultiple(array('PS_SHIPPING_FREE_PRICE', 'PS_SHIPPING_HANDLING', 'PS_SHIPPING_FREE_WEIGHT'));
     $free_fees_price = 0;
     if (isset($configuration['PS_SHIPPING_FREE_PRICE'])) {
         $free_fees_price = Tools::convertPrice((double) $configuration['PS_SHIPPING_FREE_PRICE'], Currency::getCurrencyInstance((int) $this->id_currency));
     }
     $free_fees_weight = 0;
     if (isset($configuration['PS_SHIPPING_FREE_WEIGHT'])) {
         $free_fees_weight = Tools::convertPrice((double) $configuration['PS_SHIPPING_FREE_WEIGHT'], Currency::getCurrencyInstance((int) $this->id_currency));
     }
     $shipping_method = $carrier->getShippingMethod();
     if ($shipping_method == Carrier::SHIPPING_METHOD_PRICE and $carrier_amount >= (double) $free_fees_price and (double) $free_fees_price > 0) {
     } else {
         if ($shipping_method == Carrier::SHIPPING_METHOD_WEIGHT and $carrier_weight >= (double) $free_fees_weight and (double) $free_fees_weight > 0) {
         } else {
             if ($shipping_method == Carrier::SHIPPING_METHOD_WEIGHT) {
                 $seller_shipping = $carrier->getDeliveryPriceByWeight($carrier_weight, $id_zone);
                 $shipping_cost += $seller_shipping;
             } else {
                 $seller_shipping = $carrier->getDeliveryPriceByPrice($carrier_amount, $id_zone, (int) $this->id_currency);
                 $shipping_cost += $seller_shipping;
             }
         }
     }
     $shipping_cost += $this->getAdditionalShippingCostOfSeller($id_carrier);
     if ($carrier->shipping_handling) {
         $shipping_cost += (double) Configuration::get('PS_SHIPPING_HANDLING');
     }
     if (isset($carrierTax)) {
         $shipping_cost *= 1 + $carrierTax / 100;
     }
     $shipping_cost = Tools::convertPrice($shipping_cost);
     return $shipping_cost;
 }
开发者ID:evilscripts,项目名称:gy,代码行数:43,代码来源:Cart.php

示例5: getTplRangesVarsAndValues

 /**
  * @param Carrier $carrier
  * @param array   $tpl_vars
  * @param array   $fields_value
  */
 protected function getTplRangesVarsAndValues($carrier, &$tpl_vars, &$fields_value)
 {
     $tpl_vars['zones'] = Zone::getZones(false);
     $carrier_zones = $carrier->getZones();
     $carrier_zones_ids = array();
     if (is_array($carrier_zones)) {
         foreach ($carrier_zones as $carrier_zone) {
             $carrier_zones_ids[] = $carrier_zone['id_zone'];
         }
     }
     $range_table = $carrier->getRangeTable();
     $shipping_method = $carrier->getShippingMethod();
     $zones = Zone::getZones(false);
     foreach ($zones as $zone) {
         $fields_value['zones'][$zone['id_zone']] = Tools::getValue('zone_' . $zone['id_zone'], in_array($zone['id_zone'], $carrier_zones_ids));
     }
     if ($shipping_method == Carrier::SHIPPING_METHOD_FREE) {
         $range_obj = $carrier->getRangeObject($carrier->shipping_method);
         $price_by_range = array();
     } else {
         $range_obj = $carrier->getRangeObject();
         $price_by_range = Carrier::getDeliveryPriceByRanges($range_table, (int) $carrier->id);
     }
     foreach ($price_by_range as $price) {
         $tpl_vars['price_by_range'][$price['id_' . $range_table]][$price['id_zone']] = $price['price'];
     }
     $tmp_range = $range_obj->getRanges((int) $carrier->id);
     $tpl_vars['ranges'] = array();
     if ($shipping_method != Carrier::SHIPPING_METHOD_FREE) {
         foreach ($tmp_range as $id => $range) {
             $tpl_vars['ranges'][$range['id_' . $range_table]] = $range;
             $tpl_vars['ranges'][$range['id_' . $range_table]]['id_range'] = $range['id_' . $range_table];
         }
     }
     // init blank range
     if (!count($tpl_vars['ranges'])) {
         $tpl_vars['ranges'][] = array('id_range' => 0, 'delimiter1' => 0, 'delimiter2' => 0);
     }
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:44,代码来源:AdminCarrierWizardController.php

示例6: getInternationalShippings

    public static function getInternationalShippings($id_ebay_profile, $id_product = null)
    {
        $shippings = Db::getInstance()->ExecuteS('SELECT *
			FROM ' . _DB_PREFIX_ . 'ebay_shipping 
			WHERE `id_ebay_profile` = ' . (int) $id_ebay_profile . ' 
			AND international = 1');
        //Check if product can be shipped because of weight or dimension
        if ($id_product) {
            $exclude = array();
            foreach ($shippings as $key => $value) {
                $carrier = new Carrier($value['ps_carrier']);
                $product = new Product($id_product);
                if ($carrier->range_behavior) {
                    if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT && !Carrier::checkDeliveryPriceByWeight($carrier->id, $product->weight, $value['id_zone']) || $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE && !Carrier::checkDeliveryPriceByPrice($carrier->id, $product->weight, $value['id_zone'], Configuration::get('PS_CURRENCY_DEFAULT'))) {
                        $exclude[] = $key;
                    }
                }
                if ($carrier->max_width < $product->width && $carrier->max_width != 0 || $carrier->max_height < $product->height && $carrier->max_height != 0 || $carrier->max_depth < $product->depth && $carrier->max_depth != 0) {
                    $exclude[] = $key;
                    continue;
                }
            }
            $exclude = array_unique($exclude);
            foreach ($exclude as $key_to_exclude) {
                unset($shippings[$key_to_exclude]);
            }
        }
        if ($id_product && version_compare(_PS_VERSION_, '1.5', '>')) {
            $shippings_product = Db::getInstance()->ExecuteS('SELECT id_carrier_reference as ps_carrier
			FROM ' . _DB_PREFIX_ . 'product_carrier WHERE id_product = ' . (int) $id_product);
            if (count($shippings_product) > 0) {
                if (array_intersect_assoc($shippings, $shippings_product)) {
                    $shippings = array_intersect_assoc($shippings, $shippings_product);
                }
            }
        }
        return $shippings;
    }
开发者ID:anantha89,项目名称:gpprestashop,代码行数:38,代码来源:EbayShipping.php

示例7: hookExtraCarrier

 public function hookExtraCarrier($params)
 {
     /*  TODO : Makes it work with multi-shipping */
     if (!MondialRelay::isAccountSet()) {
         return '';
     }
     $id_carrier = false;
     $preSelectedRelay = $this->getRelayPointSelected($this->context->cart->id);
     $carriersList = MondialRelay::_getCarriers();
     $address = new Address($this->context->cart->id_address_delivery);
     $country = new Country($address->id_country);
     $id_zone = Address::getZoneById((int) $address->id);
     /*  Check if the defined carrier are ok */
     foreach ($carriersList as $k => $row) {
         /*  For now works only with single shipping (>= 1.5 compatibility) */
         if (method_exists($this->context->cart, 'carrierIsSelected')) {
             if ($this->context->cart->carrierIsSelected($row['id_carrier'], $params['address']->id)) {
                 $id_carrier = $row['id_carrier'];
             }
         }
         /*  Temporary carrier for some test */
         $carrier = new Carrier((int) $row['id_carrier']);
         if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT && $carrier->getMaxDeliveryPriceByWeight($id_zone) === false || $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE && $carrier->getMaxDeliveryPriceByPrice($id_zone) === false) {
             unset($carriersList[$k]);
         } else {
             if ($row['range_behavior']) {
                 /*  Get id zone */
                 $id_zone = isset($this->context->cart->id_address_delivery) && $this->context->cart->id_address_delivery ? Address::getZoneById((int) $this->context->cart->id_address_delivery) : (int) $this->context->country->id_zone;
                 if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT && !Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $this->context->cart->getTotalWeight(), $id_zone) || $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE && (!Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $this->context->cart->getOrderTotal(true, MondialRelay::BOTH_WITHOUT_SHIPPING), $id_zone, $this->context->cart->id_currency) || !Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $this->context->cart->getOrderTotal(true, MondialRelay::BOTH_WITHOUT_SHIPPING), $id_zone, $this->context->cart->id_currency))) {
                     unset($carriersList[$k]);
                 }
             }
         }
     }
     $carrier = null;
     if ($id_carrier && ($method = MondialRelay::getMethodByIdCarrier($id_carrier))) {
         $carrier = new Carrier((int) $id_carrier);
         /*  Add dynamically a new field */
         $carrier->id_mr_method = $method['id_mr_method'];
         $carrier->mr_dlv_mode = $method['dlv_mode'];
     }
     if (Configuration::get('PS_SSL_ENABLED') || !empty($_SERVER['HTTPS']) && Tools::strtolower($_SERVER['HTTPS']) != 'off') {
         $ssl = 'true';
     } else {
         $ssl = 'false';
     }
     $this->context->smarty->assign(array('address' => $address, 'account_shop' => $this->account_shop, 'country' => $country, 'ssl' => $ssl, 'MR_Data' => MRTools::jsonEncode(array('carrier_list' => $carriersList, 'carrier' => $carrier, 'PS_VERSION' => _PS_VERSION_, 'pre_selected_relay' => isset($preSelectedRelay['MR_selected_num']) ? $preSelectedRelay['MR_selected_num'] : -1))));
     if (Configuration::get('MONDIAL_RELAY_MODE') == 'widget') {
         return $this->fetchTemplate('/views/templates/front/', 'checkout_process_widget');
     } else {
         return $this->fetchTemplate('/views/templates/front/', 'checkout_process');
     }
 }
开发者ID:studiokiwik,项目名称:mondialrelay,代码行数:53,代码来源:mondialrelay.php

示例8: getCarrierShippingRanges

    private static function getCarrierShippingRanges()
    {
        $carrier = new Carrier((int) self::$_carrierId);
        // Get only carriers that are compliant with shipping method
        if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT && $carrier->getMaxDeliveryPriceByWeight((int) self::$_zone) === false || $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE && $carrier->getMaxDeliveryPriceByPrice((int) self::$_zone) === false) {
            return array();
        }
        if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) {
            $table = 'range_weight';
        }
        if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE) {
            $table = 'range_price';
        }
        if (!in_array($table, array('range_price', 'range_weight'))) {
            return array();
        }
        $sql = '
        SELECT d.`id_' . $table . '` ,
               d.`id_carrier`        ,
               d.`id_zone`           ,
               d.`price`             ,
               r.`delimiter1`        ,
               r.`delimiter2`
        FROM `' . _DB_PREFIX_ . 'delivery` d

            LEFT JOIN `' . _DB_PREFIX_ . $table . '` r
            ON  r.`id_' . $table . '` = d.`id_' . $table . '`

        WHERE
                d.`id_' . $table . '` IS NOT NULL
            AND d.`id_' . $table . '` != 0
            AND d.price > 0
            AND d.id_carrier = ' . (int) self::$_carrierId . '
            AND d.id_zone = ' . (int) self::$_zone;
        $result = Db::getInstance()->ExecuteS($sql);
        $priceRanges = array();
        $i = 0;
        foreach ($result as $range) {
            $priceRanges[$i]['price'] = $range['price'];
            $priceRanges[$i]['from'] = $range['delimiter1'];
            $priceRanges[$i]['to'] = $range['delimiter2'];
            $i++;
        }
        return $priceRanges;
    }
开发者ID:pedalracer,项目名称:free_modules_1.5,代码行数:45,代码来源:Export.php

示例9: isCarrierInRange

 /**
  * isCarrierInRange
  *
  * Check if the specified carrier is in range
  *
  * @id_carrier int
  * @id_zone int
  */
 public function isCarrierInRange($id_carrier, $id_zone)
 {
     $carrier = new Carrier((int) $id_carrier, Configuration::get('PS_LANG_DEFAULT'));
     $is_in_zone = false;
     $order_total = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING);
     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;
 }
开发者ID:hecbuma,项目名称:quali-fisioterapia,代码行数:19,代码来源:Cart.php

示例10: getCarriersByZoneID

 function getCarriersByZoneID($id_zone)
 {
     global $cookie, $cart;
     $id_groups = array(1);
     $islogged = _PS_VERSION_ > '1.5' ? Context::getContext()->customer->isLogged() : $cookie->isLogged();
     if ($islogged) {
         $customer = new Customer((int) $cookie->id_customer);
         $id_groups = $customer->getGroups();
     }
     $result = Carrier::getCarriers(intval($cookie->id_lang), true, false, intval($id_zone), $id_groups, Carrier::ALL_CARRIERS);
     $resultsArray = array();
     foreach ($result as $k => $row) {
         $carrier = new Carrier(intval($row['id_carrier']));
         $shipping_method = $carrier->getShippingMethod();
         if ($shipping_method == Carrier::SHIPPING_METHOD_WEIGHT and $carrier->getMaxDeliveryPriceByWeight($id_zone) === false or $shipping_method == Carrier::SHIPPING_METHOD_PRICE and $carrier->getMaxDeliveryPriceByPrice($id_zone) === false) {
             unset($result[$k]);
             continue;
         }
         if ($row['range_behavior']) {
             if (Configuration::get('PS_SHIPPING_METHOD') and !Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $cart->getTotalWeight(), $id_zone) or !Configuration::get('PS_SHIPPING_METHOD') and !Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $cart->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING), $id_zone)) {
                 unset($result[$k]);
                 continue;
             }
         }
         $row['name'] = strval($row['name']) != '0' ? $row['name'] : Configuration::get('PS_SHOP_NAME');
         $method = $carrier->getShippingMethod();
         $row['price'] = 0;
         if ($method == Carrier::SHIPPING_METHOD_PRICE) {
             $row['price'] = $carrier->getDeliveryPriceByPrice($cart->getOrderTotal(Cart::BOTH_WITHOUT_SHIPPING), $id_zone);
         } else {
             if ($method == Carrier::SHIPPING_METHOD_WEIGHT) {
                 $row['price'] = $carrier->getDeliveryPriceByWeight($cart->getTotalWeight(), $id_zone);
             }
         }
         if ((int) $row['shipping_handling'] == 1) {
             $row['price'] = (double) $row['price'] + (double) Configuration::get('PS_SHIPPING_HANDLING');
         }
         if ((int) $row['is_free']) {
             $row['price'] = 0;
         }
         $row['price_tax_exc'] = $row['price'];
         $address = new Address($cart->id_address_delivery);
         $tax_rate = $carrier->getTaxesRate($address);
         $currency = new Currency($cart->id_currency);
         $row['price'] = $row['price'] * $currency->conversion_rate * (1 + (double) $tax_rate / 100);
         $row['img'] = file_exists(_PS_SHIP_IMG_DIR_ . intval($row['id_carrier']) . '.jpg') ? _THEME_SHIP_DIR_ . intval($row['id_carrier']) . '.jpg' : '';
         $resultsArray[] = $row;
     }
     return $resultsArray;
 }
开发者ID:ecssjapan,项目名称:guiding-you-afteropen,代码行数:50,代码来源:agilepaypalbase.php

示例11: isCarrierInRange

 /**
  * isCarrierInRange
  *
  * Check if the specified carrier is in range
  *
  * @id_carrier int
  * @id_zone int
  */
 public function isCarrierInRange($id_carrier, $id_zone)
 {
     $carrier = new Carrier((int) $id_carrier, _PS_LANG_DEFAULT_);
     $shippingMethod = $carrier->getShippingMethod();
     if (!$carrier->range_behavior) {
         return true;
     }
     if ($shippingMethod == Carrier::SHIPPING_METHOD_FREE) {
         return true;
     }
     if ($shippingMethod == Carrier::SHIPPING_METHOD_WEIGHT and Carrier::checkDeliveryPriceByWeight((int) $id_carrier, $this->getTotalWeight(), $id_zone)) {
         return true;
     }
     if ($shippingMethod == Carrier::SHIPPING_METHOD_PRICE and Carrier::checkDeliveryPriceByPrice((int) $id_carrier, $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING), $id_zone, (int) $this->id_currency)) {
         return true;
     }
     return false;
 }
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:26,代码来源:Cart.php

示例12: getCarriersForOrder

 /**
  * Get available Carriers for Order
  *
  * @param int       $id_zone Zone ID
  * @param array     $groups  Group of the Customer
  * @param Cart|null $cart    Optional Cart object
  * @param array     &$error  Contains an error message if an error occurs
  *
  * @return array Carriers for the order
  */
 public static function getCarriersForOrder($id_zone, $groups = null, $cart = null, &$error = array())
 {
     $context = Context::getContext();
     $id_lang = $context->language->id;
     if (is_null($cart)) {
         $cart = $context->cart;
     }
     if (isset($context->currency)) {
         $id_currency = $context->currency->id;
     }
     if (is_array($groups) && !empty($groups)) {
         $result = Carrier::getCarriers($id_lang, true, false, (int) $id_zone, $groups, self::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
     } else {
         $result = Carrier::getCarriers($id_lang, true, false, (int) $id_zone, array(Configuration::get('PS_UNIDENTIFIED_GROUP')), self::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
     }
     $results_array = array();
     foreach ($result as $k => $row) {
         $carrier = new Carrier((int) $row['id_carrier']);
         $shipping_method = $carrier->getShippingMethod();
         if ($shipping_method != Carrier::SHIPPING_METHOD_FREE) {
             // Get only carriers that are compliant with shipping method
             if ($shipping_method == Carrier::SHIPPING_METHOD_WEIGHT && $carrier->getMaxDeliveryPriceByWeight($id_zone) === false) {
                 $error[$carrier->id] = Carrier::SHIPPING_WEIGHT_EXCEPTION;
                 unset($result[$k]);
                 continue;
             }
             if ($shipping_method == Carrier::SHIPPING_METHOD_PRICE && $carrier->getMaxDeliveryPriceByPrice($id_zone) === false) {
                 $error[$carrier->id] = Carrier::SHIPPING_PRICE_EXCEPTION;
                 unset($result[$k]);
                 continue;
             }
             // If out-of-range behavior carrier is set to "Deactivate carrier"
             if ($row['range_behavior']) {
                 // Get id zone
                 if (!$id_zone) {
                     $id_zone = (int) Country::getIdZone(Country::getDefaultCountryId());
                 }
                 // Get only carriers that have a range compatible with cart
                 if ($shipping_method == Carrier::SHIPPING_METHOD_WEIGHT && !Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $cart->getTotalWeight(), $id_zone)) {
                     $error[$carrier->id] = Carrier::SHIPPING_WEIGHT_EXCEPTION;
                     unset($result[$k]);
                     continue;
                 }
                 if ($shipping_method == Carrier::SHIPPING_METHOD_PRICE && !Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $cart->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING), $id_zone, $id_currency)) {
                     $error[$carrier->id] = Carrier::SHIPPING_PRICE_EXCEPTION;
                     unset($result[$k]);
                     continue;
                 }
             }
         }
         $row['name'] = strval($row['name']) != '0' ? $row['name'] : Carrier::getCarrierNameFromShopName();
         $row['price'] = $shipping_method == Carrier::SHIPPING_METHOD_FREE ? 0 : $cart->getPackageShippingCost((int) $row['id_carrier'], true, null, null, $id_zone);
         $row['price_tax_exc'] = $shipping_method == Carrier::SHIPPING_METHOD_FREE ? 0 : $cart->getPackageShippingCost((int) $row['id_carrier'], false, null, null, $id_zone);
         $row['img'] = file_exists(_PS_SHIP_IMG_DIR_ . (int) $row['id_carrier'] . '.jpg') ? _THEME_SHIP_DIR_ . (int) $row['id_carrier'] . '.jpg' : '';
         // If price is false, then the carrier is unavailable (carrier module)
         if ($row['price'] === false) {
             unset($result[$k]);
             continue;
         }
         $results_array[] = $row;
     }
     // if we have to sort carriers by price
     $prices = array();
     if (Configuration::get('PS_CARRIER_DEFAULT_SORT') == Carrier::SORT_BY_PRICE) {
         foreach ($results_array as $r) {
             $prices[] = $r['price'];
         }
         if (Configuration::get('PS_CARRIER_DEFAULT_ORDER') == Carrier::SORT_BY_ASC) {
             array_multisort($prices, SORT_ASC, SORT_NUMERIC, $results_array);
         } else {
             array_multisort($prices, SORT_DESC, SORT_NUMERIC, $results_array);
         }
     }
     return $results_array;
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:85,代码来源:Carrier.php

示例13: getCarriersForOrder

 /**
  *
  * @param int $id_zone
  * @param Array $groups group of the customer
  * @return Array 
  */
 public static function getCarriersForOrder($id_zone, $groups = null)
 {
     global $cookie, $cart;
     if (is_array($groups) && !empty($groups)) {
         $result = Carrier::getCarriers((int) $cookie->id_lang, true, false, (int) $id_zone, $groups, self::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
     } else {
         $result = Carrier::getCarriers((int) $cookie->id_lang, true, false, (int) $id_zone, array(1), self::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
     }
     $resultsArray = array();
     foreach ($result as $k => $row) {
         $carrier = new Carrier((int) $row['id_carrier']);
         $shippingMethod = $carrier->getShippingMethod();
         if ($shippingMethod != Carrier::SHIPPING_METHOD_FREE) {
             // Get only carriers that are compliant with shipping method
             if ($shippingMethod == Carrier::SHIPPING_METHOD_WEIGHT && $carrier->getMaxDeliveryPriceByWeight($id_zone) === false || $shippingMethod == Carrier::SHIPPING_METHOD_PRICE && $carrier->getMaxDeliveryPriceByPrice($id_zone) === false) {
                 unset($result[$k]);
                 continue;
             }
             // If out-of-range behavior carrier is set on "Desactivate carrier"
             if ($row['range_behavior']) {
                 // Get id zone
                 if (!$id_zone) {
                     $id_zone = Country::getIdZone(Country::getDefaultCountryId());
                 }
                 // Get only carriers that have a range compatible with cart
                 if ($shippingMethod == Carrier::SHIPPING_METHOD_WEIGHT && !Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $cart->getTotalWeight(), $id_zone) || $shippingMethod == Carrier::SHIPPING_METHOD_PRICE && !Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $cart->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING), $id_zone, $cart->id_currency)) {
                     unset($result[$k]);
                     continue;
                 }
             }
         }
         $row['name'] = strval($row['name']) != '0' ? $row['name'] : Configuration::get('PS_SHOP_NAME');
         $row['price'] = $shippingMethod == Carrier::SHIPPING_METHOD_FREE ? 0 : $cart->getOrderShippingCost((int) $row['id_carrier']);
         $row['price_tax_exc'] = $shippingMethod == Carrier::SHIPPING_METHOD_FREE ? 0 : $cart->getOrderShippingCost((int) $row['id_carrier'], false);
         $row['img'] = file_exists(_PS_SHIP_IMG_DIR_ . (int) $row['id_carrier'] . '.jpg') ? _THEME_SHIP_DIR_ . (int) $row['id_carrier'] . '.jpg' : '';
         // If price is false, then the carrier is unavailable (carrier module)
         if ($row['price'] === false) {
             unset($result[$k]);
             continue;
         }
         $resultsArray[] = $row;
     }
     return $resultsArray;
 }
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:50,代码来源:Carrier.php

示例14: getShippingPrice

 /**
  * Récupération du prix de shipping pour un produit id
  * @param $shipping
  * @return float
  */
 public function getShippingPrice($product_id, $attribute_id, $id_carrier = 0, $id_zone = 0)
 {
     $product = new Product($product_id);
     $shipping = 0;
     $carrier = new Carrier((int) $id_carrier);
     if ($id_zone == 0) {
         $defaultCountry = new Country(Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT'));
         $id_zone = (int) $defaultCountry->id_zone;
     }
     $carrierTax = Tax::getCarrierTaxRate((int) $carrier->id);
     $free_weight = Configuration::get('PS_SHIPPING_FREE_WEIGHT');
     $shipping_handling = Configuration::get('PS_SHIPPING_HANDLING');
     if ($product->getPrice(true, $attribute_id, 2, NULL, false, true, 1) >= (double) $free_weight and (double) $free_weight > 0) {
         $shipping = 0;
     } elseif (isset($free_weight) and $product->weight >= (double) $free_weight and (double) $free_weight > 0) {
         $shipping = 0;
     } else {
         if (isset($shipping_handling) and $carrier->shipping_handling) {
             $shipping = (double) $shipping_handling;
         }
         if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) {
             $shipping += $carrier->getDeliveryPriceByWeight($product->weight, $id_zone);
         } else {
             $shipping += $carrier->getDeliveryPriceByPrice($product->getPrice(true, $attribute_id, 2, NULL, false, true, 1), $id_zone);
         }
         $shipping *= 1 + $carrierTax / 100;
         $shipping = (double) Tools::ps_round((double) $shipping, 2);
     }
     unset($product);
     return $shipping;
 }
开发者ID:juniorhq88,项目名称:PrestaShop-modules,代码行数:36,代码来源:GatewayProduct.php

示例15: shippingCostRetrieveRequest

 /**
  * @param $iso_country_code
  * @return null|string
  */
 public function shippingCostRetrieveRequest($iso_country_code)
 {
     if ($iso_country_code) {
         $cart = new Cart($this->id_cart);
         if ($id_country = Country::getByIso($iso_country_code)) {
             if ($id_zone = Country::getIdZone($id_country)) {
                 $carriers = Carrier::getCarriersForOrder($id_zone);
                 $currency = Currency::getCurrency($cart->id_currency);
                 if ($carriers) {
                     $carrier_list = array();
                     foreach ($carriers as $carrier) {
                         $c = new Carrier((int) $carrier['id_carrier']);
                         $shipping_method = $c->getShippingMethod();
                         $price = $shipping_method == Carrier::SHIPPING_METHOD_FREE ? 0 : $cart->getOrderShippingCost((int) $carrier['id_carrier']);
                         $price_tax_exc = $shipping_method == Carrier::SHIPPING_METHOD_FREE ? 0 : $cart->getOrderShippingCost((int) $carrier['id_carrier'], false);
                         $carrier_list[]['ShippingCost'] = array('Type' => $carrier['name'] . ' (' . $carrier['id_carrier'] . ')', 'CountryCode' => Tools::strtoupper($iso_country_code), 'Price' => array('Gross' => $this->toAmount($price), 'Net' => $this->toAmount($price_tax_exc), 'Tax' => $this->toAmount($price) - $this->toAmount($price_tax_exc), 'CurrencyCode' => Tools::strtoupper($currency['iso_code'])));
                     }
                     $shipping_cost = array('CountryCode' => Tools::strtoupper($iso_country_code), 'ShipToOtherCountry' => 'true', 'ShippingCostList' => $carrier_list);
                     $xml = OpenPayU::buildShippingCostRetrieveResponse($shipping_cost, $this->id_request, $iso_country_code);
                     return $xml;
                 } else {
                     Logger::addLog('carrier by id_zone is undefined');
                 }
             }
         }
     }
     return null;
 }
开发者ID:bonekost,项目名称:plugin_prestashop,代码行数:32,代码来源:payu.php


注:本文中的Carrier::getShippingMethod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。