本文整理汇总了PHP中Carrier::checkDeliveryPriceByPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP Carrier::checkDeliveryPriceByPrice方法的具体用法?PHP Carrier::checkDeliveryPriceByPrice怎么用?PHP Carrier::checkDeliveryPriceByPrice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Carrier
的用法示例。
在下文中一共展示了Carrier::checkDeliveryPriceByPrice方法的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;
}
示例2: getOrderShippingCost
/**
* Return shipping total
*
* @param integer $id_carrier Carrier ID (default : current carrier)
* @return float Shipping total
*/
function getOrderShippingCost($id_carrier = NULL, $useTax = true)
{
global $defaultCountry;
if ($this->isVirtualCart()) {
return 0;
}
// Checking discounts in cart
$products = $this->getProducts();
$discounts = $this->getDiscounts(true);
if ($discounts) {
foreach ($discounts as $id_discount) {
$discount = new Discount(intval($id_discount['id_discount']));
if (!Validate::isLoadedObject($discount)) {
die(Tools::displayError());
}
if ($discount->id_discount_type == 3) {
$total_cart = 0;
$categories = Discount::getCategories($discount->id);
foreach ($products as $product) {
if (count($categories)) {
if (Product::idIsOnCategoryId($product['id_product'], $categories)) {
$total_cart += $product['total_wt'];
}
}
}
if ($total_cart >= $discount->minimal) {
return 0;
}
}
}
}
// Order total without fees
$orderTotal = $this->getOrderTotal(true, 7);
// Start with shipping cost at 0
$shipping_cost = 0;
// If no product added, return 0
if ($orderTotal <= 0 and !intval(self::getNbProducts($this->id))) {
return $shipping_cost;
}
// If no carrier, select default one
if (!$id_carrier) {
$id_carrier = $this->id_carrier;
}
if (empty($id_carrier)) {
$id_carrier = Configuration::get('PS_CARRIER_DEFAULT');
}
if (!isset(self::$_carriers[$id_carrier])) {
self::$_carriers[$id_carrier] = new Carrier(intval($id_carrier));
}
$carrier = self::$_carriers[$id_carrier];
if (!Validate::isLoadedObject($carrier)) {
die(Tools::displayError('Hack attempt: "no default carrier"'));
}
if (!$carrier->active) {
return $shipping_cost;
}
// Get id zone
if (isset($this->id_address_delivery) and $this->id_address_delivery) {
$id_zone = Address::getZoneById(intval($this->id_address_delivery));
} else {
$id_zone = intval($defaultCountry->id_zone);
}
// Select carrier tax
if ($useTax and $carrier->id_tax) {
if (!isset(self::$_taxes[$carrier->id_tax])) {
self::$_taxes[$carrier->id_tax] = new Tax(intval($carrier->id_tax));
}
$tax = self::$_taxes[$carrier->id_tax];
if (Validate::isLoadedObject($tax) and Tax::zoneHasTax(intval($tax->id), intval($id_zone)) and !Tax::excludeTaxeOption()) {
$carrierTax = $tax->rate;
}
}
$configuration = Configuration::getMultiple(array('PS_SHIPPING_FREE_PRICE', 'PS_SHIPPING_HANDLING', 'PS_SHIPPING_METHOD', 'PS_SHIPPING_FREE_WEIGHT'));
// Free fees
if (isset($configuration['PS_SHIPPING_FREE_PRICE']) and $orderTotal >= floatval($configuration['PS_SHIPPING_FREE_PRICE']) and floatval($configuration['PS_SHIPPING_FREE_PRICE']) > 0) {
return $shipping_cost;
}
if (isset($configuration['PS_SHIPPING_FREE_WEIGHT']) and $this->getTotalWeight() >= floatval($configuration['PS_SHIPPING_FREE_WEIGHT']) and floatval($configuration['PS_SHIPPING_FREE_WEIGHT']) > 0) {
return $shipping_cost;
}
// Get shipping cost using correct method
if ($carrier->range_behavior) {
// Get id zone
if (isset($this->id_address_delivery) and $this->id_address_delivery) {
$id_zone = Address::getZoneById(intval($this->id_address_delivery));
} else {
$id_zone = intval($defaultCountry->id_zone);
}
if (Configuration::get('PS_SHIPPING_METHOD') and !Carrier::checkDeliveryPriceByWeight($carrier->id, $this->getTotalWeight(), $id_zone) or !Configuration::get('PS_SHIPPING_METHOD') and !Carrier::checkDeliveryPriceByPrice($carrier->id, $this->getOrderTotal(true, 4), $id_zone)) {
$shipping_cost += 0;
} else {
if (intval($configuration['PS_SHIPPING_METHOD'])) {
$shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight(), $id_zone);
} else {
//.........这里部分代码省略.........
示例3: 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;
}
示例4: 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;
}
示例5: 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');
}
}
示例6: getPackageShippingCost
public function getPackageShippingCost($id_carrier = null, $use_tax = true, Country $default_country = null, $product_list = null, $id_zone = null)
{
if (!Configuration::get('LEGAL_SHIPTAXMETH')) {
return parent::getPackageShippingCost($id_carrier, $use_tax, $default_country, $product_list, $id_zone);
}
if ($this->isVirtualCart()) {
return 0;
}
if (!$default_country) {
$default_country = Context::getContext()->country;
}
if (!is_null($product_list)) {
foreach ($product_list as $key => $value) {
if ($value['is_virtual'] == 1) {
unset($product_list[$key]);
}
}
}
$complete_product_list = $this->getProducts();
if (is_null($product_list)) {
$products = $complete_product_list;
} else {
$products = $product_list;
}
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_invoice') {
$address_id = (int) $this->id_address_invoice;
} elseif (count($product_list)) {
$prod = current($product_list);
$address_id = (int) $prod['id_address_delivery'];
} else {
$address_id = null;
}
if (!Address::addressExists($address_id)) {
$address_id = null;
}
$cache_id = 'getPackageShippingCost_' . (int) $this->id . '_' . (int) $address_id . '_' . (int) $id_carrier . '_' . (int) $use_tax . '_' . (int) $default_country->id;
if ($products) {
foreach ($products as $product) {
$cache_id .= '_' . (int) $product['id_product'] . '_' . (int) $product['id_product_attribute'];
}
}
if (Cache::isStored($cache_id)) {
return Cache::retrieve($cache_id);
}
// Order total in default currency without fees
$order_total = $this->getOrderTotal(true, Cart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING, $product_list);
// Start with shipping cost at 0
$shipping_cost = 0;
// If no product added, return 0
if (!count($products)) {
Cache::store($cache_id, $shipping_cost);
return $shipping_cost;
}
if (!isset($id_zone)) {
// Get id zone
if (!$this->isMultiAddressDelivery() && isset($this->id_address_delivery) && $this->id_address_delivery && Customer::customerHasAddress($this->id_customer, $this->id_address_delivery)) {
$id_zone = Address::getZoneById((int) $this->id_address_delivery);
} else {
if (!Validate::isLoadedObject($default_country)) {
$default_country = new Country(Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT'));
}
$id_zone = (int) $default_country->id_zone;
}
}
if ($id_carrier && !$this->isCarrierInRange((int) $id_carrier, (int) $id_zone)) {
$id_carrier = '';
}
if (empty($id_carrier) && $this->isCarrierInRange((int) Configuration::get('PS_CARRIER_DEFAULT'), (int) $id_zone)) {
$id_carrier = (int) Configuration::get('PS_CARRIER_DEFAULT');
}
$total_package_without_shipping_tax_inc = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, $product_list);
if (empty($id_carrier)) {
if ((int) $this->id_customer) {
$customer = new Customer((int) $this->id_customer);
$result = Carrier::getCarriers((int) Configuration::get('PS_LANG_DEFAULT'), true, false, (int) $id_zone, $customer->getGroups());
unset($customer);
} else {
$result = Carrier::getCarriers((int) Configuration::get('PS_LANG_DEFAULT'), true, false, (int) $id_zone);
}
foreach ($result as $k => $row) {
if ($row['id_carrier'] == Configuration::get('PS_CARRIER_DEFAULT')) {
continue;
}
if (!isset(self::$_carriers[$row['id_carrier']])) {
self::$_carriers[$row['id_carrier']] = new Carrier((int) $row['id_carrier']);
}
$carrier = self::$_carriers[$row['id_carrier']];
// Get only carriers that are compliant with shipping method
if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT && $carrier->getMaxDeliveryPriceByWeight((int) $id_zone) === false || $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE && $carrier->getMaxDeliveryPriceByPrice((int) $id_zone) === false) {
unset($result[$k]);
continue;
}
// If out-of-range behavior carrier is set on "Desactivate carrier"
if ($row['range_behavior']) {
$check_delivery_price_by_weight = Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $this->getTotalWeight(), (int) $id_zone);
$total_order = $total_package_without_shipping_tax_inc;
$check_delivery_price_by_price = Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $total_order, (int) $id_zone, (int) $this->id_currency);
// Get only carriers that have a range compatible with cart
if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT && !$check_delivery_price_by_weight || $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE && !$check_delivery_price_by_price) {
unset($result[$k]);
//.........这里部分代码省略.........
示例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);
$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 (Configuration::get('PS_SHIPPING_METHOD') && $carrier->getMaxDeliveryPriceByWeight($id_zone) === false || !Configuration::get('PS_SHIPPING_METHOD') && $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 (Configuration::get('PS_SHIPPING_METHOD') && !Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $this->context->cart->getTotalWeight(), $id_zone) || !Configuration::get('PS_SHIPPING_METHOD') && (!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 (_PS_VERSION_ >= '1.5') {
$id_carrier = (int) $this->context->cart->id_carrier;
}
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'];
}
$this->context->smarty->assign(array('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'] : 0))));
return $this->fetchTemplate('/tpl/', 'checkout_process');
}
示例8: checkSoCarrierAvailable
private function checkSoCarrierAvailable($id_carrier)
{
global $cart, $defaultCountry;
$carrier = new Carrier((int) $id_carrier);
$address = new Address((int) $cart->id_address_delivery);
$id_zone = Address::getZoneById((int) $address->id);
// Get only carriers that are compliant with shipping method
if (Configuration::get('PS_SHIPPING_METHOD') and $carrier->getMaxDeliveryPriceByWeight($id_zone) === false or !Configuration::get('PS_SHIPPING_METHOD') and $carrier->getMaxDeliveryPriceByPrice($id_zone) === false) {
return false;
}
// If out-of-range behavior carrier is set on "Desactivate carrier"
if ($carrier->range_behavior) {
// Get id zone
if (isset($cart->id_address_delivery) and $cart->id_address_delivery) {
$id_zone = Address::getZoneById((int) $cart->id_address_delivery);
} else {
$id_zone = (int) $defaultCountry->id_zone;
}
// Get only carriers that have a range compatible with cart
if (Configuration::get('PS_SHIPPING_METHOD') and !Carrier::checkDeliveryPriceByWeight((int) $carrier->id, $cart->getTotalWeight(), $id_zone) or !Configuration::get('PS_SHIPPING_METHOD') and !Carrier::checkDeliveryPriceByPrice((int) $carrier->id, $cart->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING), $id_zone, $cart->id_currency)) {
return false;
}
}
return true;
}
示例9: hookextraCarrier
public function hookextraCarrier($params)
{
global $smarty, $cart, $cookie, $defaultCountry, $nbcarriers;
if (Configuration::get('MR_ENSEIGNE_WEBSERVICE') == '' || Configuration::get('MR_CODE_MARQUE') == '' || Configuration::get('MR_KEY_WEBSERVICE') == '' || Configuration::get('MR_LANGUAGE') == '') {
return '';
}
$address = new Address((int) $cart->id_address_delivery);
$id_zone = Address::getZoneById((int) $address->id);
$carriersList = self::_getCarriers();
// Check if the defined carrier are ok
foreach ($carriersList as $k => $row) {
$carrier = new Carrier((int) $row['id_carrier']);
if ((Configuration::get('PS_SHIPPING_METHOD') and $carrier->getMaxDeliveryPriceByWeight($id_zone) === false) || (!Configuration::get('PS_SHIPPING_METHOD') and $carrier->getMaxDeliveryPriceByPrice($id_zone) === false)) {
unset($carriersList[$k]);
} else {
if ($row['range_behavior']) {
// Get id zone
$id_zone = (isset($cart->id_address_delivery) and $cart->id_address_delivery) ? Address::getZoneById((int) $cart->id_address_delivery) : (int) $defaultCountry->id_zone;
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, self::BOTH_WITHOUT_SHIPPING), $id_zone, $cart->id_currency)) {
unset($carriersList[$k]);
}
}
}
}
$preSelectedRelay = $this->getRelayPointSelected($params['cart']->id);
$smarty->assign(array('one_page_checkout' => Configuration::get('PS_ORDER_PROCESS_TYPE') ? Configuration::get('PS_ORDER_PROCESS_TYPE') : 0, 'new_base_dir' => self::$moduleURL, 'MRToken' => self::$MRFrontToken, 'carriersextra' => $carriersList, 'preSelectedRelay' => isset($preSelectedRelay['MR_selected_num']) ? $preSelectedRelay['MR_selected_num'] : '', 'jQueryOverload' => self::getJqueryCompatibility(false)));
return $this->display(__FILE__, 'mondialrelay.tpl');
}
示例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;
}
示例11: hookextraCarrier
public function hookextraCarrier($params)
{
global $smarty, $cart, $cookie, $defaultCountry, $nbcarriers;
if (Configuration::get('MR_ENSEIGNE_WEBSERVICE') == '' or Configuration::get('MR_CODE_MARQUE') == '' or Configuration::get('MR_KEY_WEBSERVICE') == '' or Configuration::get('MR_LANGUAGE') == '') {
return '';
}
$totalweight = Configuration::get('MR_WEIGHT_COEF') * $cart->getTotalWeight();
if (Validate::isUnsignedInt($cart->id_carrier)) {
$carrier = new Carrier((int) $cart->id_carrier);
if ($carrier->active and !$carrier->deleted) {
$checked = (int) $cart->id_carrier;
}
}
if (!isset($checked) or $checked == 0) {
$checked = (int) Configuration::get('PS_CARRIER_DEFAULT');
}
$address = new Address((int) $cart->id_address_delivery);
$id_zone = Address::getZoneById((int) $address->id);
$country = new Country((int) $address->id_country);
$query = self::getmrth((int) $cookie->id_lang, true, (int) $country->id_zone, $country->iso_code);
$resultsArray = array();
$i = 0;
foreach ($query as $k => $row) {
$carrier = new Carrier((int) $row['id_carrier']);
if (Configuration::get('PS_SHIPPING_METHOD') and $carrier->getMaxDeliveryPriceByWeight($id_zone) === false or !Configuration::get('PS_SHIPPING_METHOD') and $carrier->getMaxDeliveryPriceByPrice($id_zone) === false) {
unset($result[$k]);
continue;
}
if ($row['range_behavior']) {
// Get id zone
if (isset($cart->id_address_delivery) and $cart->id_address_delivery) {
$id_zone = Address::getZoneById((int) $cart->id_address_delivery);
} else {
$id_zone = (int) $defaultCountry->id_zone;
}
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, self::BOTH_WITHOUT_SHIPPING), $id_zone, $cart->id_currency)) {
unset($result[$k]);
continue;
}
}
$settings = Db::getInstance()->ExecuteS('SELECT * FROM `' . _DB_PREFIX_ . 'mr_method` WHERE `id_carrier` = ' . (int) $row['id_carrier']);
$row['name'] = $settings[0]['mr_Name'];
$row['col'] = $settings[0]['mr_ModeCol'];
$row['liv'] = $settings[0]['mr_ModeLiv'];
$row['ass'] = $settings[0]['mr_ModeAss'];
$row['price'] = $cart->getOrderShippingCost((int) $row['id_carrier']);
$row['img'] = file_exists(_PS_SHIP_IMG_DIR_ . (int) $row['id_carrier'] . '.jpg') ? _THEME_SHIP_DIR_ . (int) $row['id_carrier'] . '.jpg' : '';
$resultsArray[] = $row;
$i++;
}
if ($i > 0) {
include_once _PS_MODULE_DIR_ . 'mondialrelay/page_iso.php';
$smarty->assign(array('address_map' => $address->address1 . ', ' . $address->postcode . ', ' . ote_accent($address->city) . ', ' . $country->iso_code, 'input_cp' => $address->postcode, 'input_ville' => ote_accent($address->city), 'input_pays' => $country->iso_code, 'input_poids' => Configuration::get('MR_WEIGHT_COEF') * $cart->getTotalWeight(), 'nbcarriers' => $nbcarriers, 'checked' => (int) $checked, 'google_api_key' => Configuration::get('MR_GOOGLE_MAP'), 'one_page_checkout' => Configuration::get('PS_ORDER_PROCESS_TYPE') ? Configuration::get('PS_ORDER_PROCESS_TYPE') : 0, 'new_base_dir' => self::$moduleURL, 'carriersextra' => $resultsArray));
$nbcarriers = $nbcarriers + $i;
return $this->display(__FILE__, 'mondialrelay.tpl');
}
}
示例12: 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;
}
示例13: checkSoCarrierAvailable
private function checkSoCarrierAvailable($id_carrier)
{
$carrier = new Carrier((int) $id_carrier);
$address = new Address((int) $this->context->cart->id_address_delivery);
$id_zone = Address::getZoneById((int) $address->id);
// backward compatibility
if (version_compare(_PS_VERSION_, '1.5', '<')) {
// Get only carriers that are compliant with shipping method
if (Configuration::get('PS_SHIPPING_METHOD') && $carrier->getMaxDeliveryPriceByWeight($id_zone) === false || !Configuration::get('PS_SHIPPING_METHOD') && $carrier->getMaxDeliveryPriceByPrice($id_zone) === false) {
return false;
}
} else {
if ($carrier->shipping_method) {
if ($carrier->shipping_method == 1 && $carrier->getMaxDeliveryPriceByWeight($id_zone) === false || $carrier->shipping_method == 2 && $carrier->getMaxDeliveryPriceByPrice($id_zone) === false) {
return false;
}
} else {
if (Configuration::get('PS_SHIPPING_METHOD') && $carrier->getMaxDeliveryPriceByWeight($id_zone) === false || !Configuration::get('PS_SHIPPING_METHOD') && $carrier->getMaxDeliveryPriceByPrice($id_zone) === false) {
return false;
}
}
}
// If out-of-range behavior carrier is set on "Desactivate carrier"
if ($carrier->range_behavior) {
// Get id zone
$id_zone = (int) $this->context->country->id_zone;
if (isset($this->context->cart->id_address_delivery) && $this->context->cart->id_address_delivery) {
$id_zone = Address::getZoneById((int) $this->context->cart->id_address_delivery);
}
if (version_compare(_PS_VERSION_, '1.5', '<')) {
// Get only carriers that have a range compatible with cart
if (Configuration::get('PS_SHIPPING_METHOD') && !Carrier::checkDeliveryPriceByWeight((int) $carrier->id, $this->context->cart->getTotalWeight(), $id_zone) || !Configuration::get('PS_SHIPPING_METHOD') && !Carrier::checkDeliveryPriceByPrice((int) $carrier->id, $this->context->cart->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING), $id_zone, $this->context->cart->id_currency)) {
return false;
}
} else {
if ($carrier->shipping_method) {
if ($carrier->shipping_method == 1 && !Carrier::checkDeliveryPriceByWeight((int) $carrier->id, $this->context->cart->getTotalWeight(), $id_zone) || $carrier->shipping_method == 2 && !Carrier::checkDeliveryPriceByPrice((int) $carrier->id, $this->context->cart->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING), $id_zone, $this->context->cart->id_currency)) {
return false;
}
} else {
if (Configuration::get('PS_SHIPPING_METHOD') && !Carrier::checkDeliveryPriceByWeight((int) $carrier->id, $this->context->cart->getTotalWeight(), $id_zone) || !Configuration::get('PS_SHIPPING_METHOD') && !Carrier::checkDeliveryPriceByPrice((int) $carrier->id, $this->context->cart->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING), $id_zone, $this->context->cart->id_currency)) {
return false;
}
}
}
}
return true;
}
示例14: isCarrierInRange
private function isCarrierInRange($carrier, $id_zone)
{
if (!$carrier->range_behavior) {
PowaTagLogs::initAPILog('isCarrierInRange', PowaTagLogs::SUCCESS, '! carrier->range_behavior');
return true;
}
$shipping_method = $carrier->getShippingMethod();
if ($shipping_method == Carrier::SHIPPING_METHOD_FREE) {
PowaTagLogs::initAPILog('isCarrierInRange', PowaTagLogs::SUCCESS, 'shipping_method == Carrier::SHIPPING_METHOD_FREE');
return true;
}
$check_delivery_price_by_weight = Carrier::checkDeliveryPriceByWeight((int) $carrier->id, null, $id_zone);
if ($shipping_method == Carrier::SHIPPING_METHOD_WEIGHT && $check_delivery_price_by_weight) {
PowaTagLogs::initAPILog('isCarrierInRange', PowaTagLogs::SUCCESS, 'shipping_method == Carrier::SHIPPING_METHOD_WEIGHT ...');
return true;
}
$check_delivery_price_by_price = Carrier::checkDeliveryPriceByPrice((int) $carrier->id, $this->subTotal, $id_zone, (int) $this->id_currency);
if ($shipping_method == Carrier::SHIPPING_METHOD_PRICE && $check_delivery_price_by_price) {
PowaTagLogs::initAPILog('isCarrierInRange', PowaTagLogs::SUCCESS, 'shipping_method == Carrier::SHIPPING_METHOD_PRICE ...');
return true;
}
PowaTagLogs::initAPILog('isCarrierInRange', PowaTagLogs::ERROR, 'No suitable shipping method found');
return false;
}
示例15: displayCarrier
function displayCarrier()
{
global $smarty, $cart, $cookie, $defaultCountry, $link;
$address = new Address(intval($cart->id_address_delivery));
$id_zone = Address::getZoneById(intval($address->id));
if (isset($cookie->id_customer)) {
$customer = new Customer(intval($cookie->id_customer));
} else {
die(Tools::displayError($this->l('Fatal error: No customer')));
}
$result = Carrier::getCarriers(intval($cookie->id_lang), true, false, intval($id_zone), $customer->getGroups());
if (!$result) {
$result = Carrier::getCarriers(intval($cookie->id_lang), true, false, intval($id_zone));
}
$resultsArray = array();
foreach ($result as $k => $row) {
$carrier = new Carrier(intval($row['id_carrier']));
// Get only carriers that are compliant with shipping method
if (Configuration::get('PS_SHIPPING_METHOD') and $carrier->getMaxDeliveryPriceByWeight($id_zone) === false or !Configuration::get('PS_SHIPPING_METHOD') and $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 (isset($cart->id_address_delivery) and $cart->id_address_delivery) {
$id_zone = Address::getZoneById(intval($cart->id_address_delivery));
} else {
$id_zone = intval($defaultCountry->id_zone);
}
// Get only carriers that have a range compatible with cart
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, 4), $id_zone)) {
unset($result[$k]);
continue;
}
}
$row['name'] = strval($row['name']) != '0' ? $row['name'] : Configuration::get('PS_SHOP_NAME');
$row['price'] = $cart->getOrderShippingCost(intval($row['id_carrier']));
$row['price_tax_exc'] = $cart->getOrderShippingCost(intval($row['id_carrier']), false);
$row['img'] = file_exists(_PS_SHIP_IMG_DIR_ . intval($row['id_carrier']) . '.jpg') ? _THEME_SHIP_DIR_ . intval($row['id_carrier']) . '.jpg' : '';
$resultsArray[] = $row;
}
// Wrapping fees
$wrapping_fees = floatval(Configuration::get('PS_GIFT_WRAPPING_PRICE'));
$wrapping_fees_tax = new Tax(intval(Configuration::get('PS_GIFT_WRAPPING_TAX')));
$wrapping_fees_tax_inc = $wrapping_fees * (1 + floatval($wrapping_fees_tax->rate) / 100);
if (Validate::isUnsignedInt($cart->id_carrier) and $cart->id_carrier) {
$carrier = new Carrier(intval($cart->id_carrier));
if ($carrier->active and !$carrier->deleted) {
$checked = intval($cart->id_carrier);
}
}
$cms = new CMS(3, intval($cookie->id_lang));
$link_conditions = $link->getCMSLink($cms, $cms->link_rewrite);
if (!strpos($link_conditions, '?')) {
$link_conditions .= '?content_only=1&TB_iframe=true&width=450&height=500&thickbox=true';
} else {
$link_conditions .= '&content_only=1&TB_iframe=true&width=450&height=500&thickbox=true';
}
if (!isset($checked) or intval($checked) == 0) {
$checked = intval(Configuration::get('PS_CARRIER_DEFAULT'));
}
$smarty->assign(array('checkedTOS' => intval($cookie->checkedTOS), 'recyclablePackAllowed' => intval(Configuration::get('PS_RECYCLABLE_PACK')), 'giftAllowed' => intval(Configuration::get('PS_GIFT_WRAPPING')), 'conditions' => intval(Configuration::get('PS_CONDITIONS')), 'link_conditions' => $link_conditions, 'recyclable' => intval($cart->recyclable), 'gift_wrapping_price' => floatval(Configuration::get('PS_GIFT_WRAPPING_PRICE')), 'carriers' => $resultsArray, 'HOOK_EXTRACARRIER' => Module::hookExec('extraCarrier', array('address' => $address)), 'checked' => intval($checked), 'total_wrapping' => Tools::convertPrice($wrapping_fees_tax_inc, new Currency(intval($cookie->id_currency))), 'total_wrapping_tax_exc' => Tools::convertPrice($wrapping_fees, new Currency(intval($cookie->id_currency)))));
Tools::safePostVars();
$css_files = array(__PS_BASE_URI__ . 'css/thickbox.css' => 'all');
$js_files = array(__PS_BASE_URI__ . 'js/jquery/thickbox-modified.js');
include_once dirname(__FILE__) . '/header.php';
$smarty->display(_PS_THEME_DIR_ . 'order-carrier.tpl');
}