本文整理汇总了PHP中Carrier::getDeliveryPriceByPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP Carrier::getDeliveryPriceByPrice方法的具体用法?PHP Carrier::getDeliveryPriceByPrice怎么用?PHP Carrier::getDeliveryPriceByPrice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Carrier
的用法示例。
在下文中一共展示了Carrier::getDeliveryPriceByPrice方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: _getShippingPriceForProduct
private static function _getShippingPriceForProduct($product, $zone, $carrier_id)
{
$carrier = new Carrier($carrier_id);
if ($carrier->shipping_method == 0) {
// Default
if (Configuration::get('PS_SHIPPING_METHOD') == 1) {
// Shipping by weight
$price = $carrier->getDeliveryPriceByWeight($product->weight, $zone);
} else {
// Shipping by price
$price = $carrier->getDeliveryPriceByPrice($product->price, $zone);
}
} else {
if ($carrier->shipping_method == 1) {
// Shipping by weight
$price = $carrier->getDeliveryPriceByWeight($product->weight, $zone);
} else {
if ($carrier->shipping_method == 2) {
// Shipping by price
$price = $carrier->getDeliveryPriceByPrice($product->price, $zone);
} else {
// return 0 if is an other shipping method
return 0;
}
}
}
if ($carrier->shipping_handling) {
//Add shipping handling fee
$price += Configuration::get('PS_SHIPPING_HANDLING');
}
$price += $price * Tax::getCarrierTaxRate($carrier_id) / 100;
return $price;
}
示例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";
}
}
示例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;
}
示例5: getPriceByPrestaShopCalculationType
private function getPriceByPrestaShopCalculationType($carrier_shipping_method, Carrier $carrier, $cart_total, $zone, $additional_shipping_cost, $handling_charges, $is_cod_method, $order_total_price, DpdGroupConfiguration $configuration, $price_rule)
{
if ($carrier_shipping_method == Carrier::SHIPPING_METHOD_WEIGHT) {
$carrier_price = $carrier->getDeliveryPriceByWeight($cart_total, $zone);
} else {
$carrier_price = $carrier->getDeliveryPriceByPrice($cart_total, $zone);
}
$default_currency = new Currency((int) Configuration::get('PS_CURRENCY_DEFAULT', null, null, 0));
$carrier_price = $this->convertPriceByCurrency($carrier_price, $default_currency->iso_code);
$shipping_price_with_charges = $carrier_price + $additional_shipping_cost + $handling_charges;
$cod_price = 0;
if (!empty($price_rule) && $is_cod_method) {
if ($price_rule['cod_surcharge'] !== '') {
$cod_price = $this->convertPriceByCurrency($price_rule['cod_surcharge'], $price_rule['currency']);
} elseif ($price_rule['cod_surcharge_percentage'] !== '') {
$percentage_starting_price = $configuration->cod_percentage_calculation == DpdGroupConfiguration::COD_PERCENTAGE_CALCULATION_CART ? $order_total_price : $order_total_price + $shipping_price_with_charges;
$cod_price = $this->calculateCODSurchargePercentage($percentage_starting_price, $price_rule['cod_surcharge_percentage'], $price_rule['cod_min_surcharge'], $price_rule['currency']);
}
}
return $shipping_price_with_charges + $cod_price;
}
示例6: hookProductFooter
public function hookProductFooter($params)
{
global $cookie, $smarty;
$pr = new Product($params['product']->id);
$carriers = Carrier::getCarriers($cookie->id_lang);
$c = array();
foreach ($carriers as $carrier) {
$a = new Carrier($carrier['id_carrier']);
if (!Tax::excludeTaxeOption()) {
$carrierTax = Tax::getCarrierTaxRate((int) $a->id);
}
$price = $a->getDeliveryPriceByPrice($pr->getPrice(true, null), 1) * (1 + $carrierTax / 100);
$c[] = array('name' => $a->name, 'price' => $price);
}
$smarty->assign('carriers', $c);
$smarty->assign('free', (int) Configuration::get('PS_SHIPPING_FREE_PRICE'));
$smarty->assign(array('delivery' => $this->doruceni()));
return $this->display(__FILE__, 'blank_deliverytime.tpl');
}
示例7: 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;
}
示例8: getShippingPriceForProduct
private function getShippingPriceForProduct($product, $zone, $carrierid)
{
$carrier = new Carrier($carrierid);
if (Configuration::get('PS_SHIPPING_METHOD') == 1) {
//Shipping by weight
$price = $carrier->getDeliveryPriceByWeight($product->weight, $zone);
} else {
//Shipping by price
$price = $carrier->getDeliveryPriceByPrice($product->price, $zone);
}
if ($carrier->shipping_handling) {
//Add shipping handling fee (frais de manutention)
$price += Configuration::get('PS_SHIPPING_HANDLING');
}
$taxrate = Tax::getCarrierTaxRate($carrierid);
$price += $price * $taxrate / 100;
return $price;
}