本文整理汇总了PHP中Carrier::getMaxDeliveryPriceByWeight方法的典型用法代码示例。如果您正苦于以下问题:PHP Carrier::getMaxDeliveryPriceByWeight方法的具体用法?PHP Carrier::getMaxDeliveryPriceByWeight怎么用?PHP Carrier::getMaxDeliveryPriceByWeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Carrier
的用法示例。
在下文中一共展示了Carrier::getMaxDeliveryPriceByWeight方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: displayOrderStep
function displayOrderStep($params)
{
global $smarty, $cart, $cookie, $defaultCountry;
if ($isVirtualCart = $cart->isVirtualCart()) {
$cart->id_carrier = 0;
$cart->update();
}
$smarty->assign('virtual_cart', $isVirtualCart);
$address = new Address(intval($cart->id_address_delivery));
$id_zone = Address::getZoneById($address->id);
$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']));
if (Configuration::get('PS_SHIPPING_METHOD') and !$carrier->getMaxDeliveryPriceByWeight($id_zone) or !Configuration::get('PS_SHIPPING_METHOD') and !$carrier->getMaxDeliveryPriceByPrice($id_zone)) {
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(intval($cart->id_address_delivery));
} else {
$id_zone = intval($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->getOrderTotalLC(true, 4), $id_zone)) {
unset($result[$k]);
continue;
}
}
$row['name'] = strval($row['name']) != '0' ? $row['name'] : Configuration::get('PS_SHOP_NAME');
$row['price'] = $cart->getOrderShippingCostLC(intval($row['id_carrier']));
$row['price_tax_exc'] = $cart->getOrderShippingCostLC(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' : '';
$row['extra'] = Module::hookExec('extraCarrierDetails', array("row" => $row, "carrier" => $carrier));
$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_exc = $wrapping_fees / (1 + floatval($wrapping_fees_tax->rate) / 100);
if (Validate::isUnsignedInt($cart->id_carrier)) {
$carrier = new Carrier(intval($cart->id_carrier));
if ($carrier->active and !$carrier->deleted) {
$checked = intval($cart->id_carrier);
}
}
if (!isset($checked)) {
$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')), '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), 'back' => strval(Tools::getValue('back')), 'total_wrapping' => number_format($wrapping_fees, 2, '.', ''), 'total_wrapping_tax_exc' => number_format($wrapping_fees_tax_exc, 2, '.', '')));
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';
echo $this->display(__FILE__, 'ordercarrier.tpl');
}
示例2: 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;
}
示例3: 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');
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: hookextraCarrier
public function hookextraCarrier($params)
{
if (!MondialRelay::isAccountSet()) {
return '';
}
$carrier = false;
$id_carrier = false;
$id_mr_method = false;
$preSelectedRelay = $this->getRelayPointSelected($params['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 !
if (method_exists($params['cart'], 'carrierIsSelected')) {
if ($params['cart']->carrierIsSelected($row['id_carrier'], $params['address']->id)) {
$id_carrier = $row['id_carrier'];
}
}
$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($this->context->cart->id_address_delivery) and $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 = MondialRelay::getMethodByIdCarrier($id_carrier);
$this->context->smarty->assign(array('carriersextra' => $carriersList, 'preSelectedRelay' => isset($preSelectedRelay['MR_selected_num']) ? $preSelectedRelay['MR_selected_num'] : '', 'MR_carrier' => $carrier, 'MR_PS_VERSION' => _PS_VERSION_, 'MR_dlv_mode' => $id_carrier ? $carrier['dlv_mode'] : ''));
return $this->fetchTemplate('/tpl/', 'checkout_process');
}
示例8: 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');
}
示例9: 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');
}
示例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: 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;
}
示例13: 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');
}
}