Prestashop 1.7.4.2 - 基于最终总价的免费送货
Prestashop 1.7.4.2 - free shipping based on final total price
我需要计算折扣后的运费
例如
总购物车:65$
免费送货开始:65$
折扣:5%
折扣后低于 65 美元仍然免费送货
我需要它来计算发货前的折扣
首先按运营商设置范围(0-65:X 欧元,65 以上:0 欧元)
覆盖 class Cart.php
Rewrite function getPackageShippingCost
行后
// Order total in default currency without fees
$order_total = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, $product_list);
添加这个
//Recalcul total pour panier et livraison gratuite
$listeDiscounts = $this->getCartRules();
$total_discounts = 0;
if (is_array($listeDiscounts)) {
if (isset($listeDiscounts[0]['value_real']))
$total_discounts = $listeDiscounts[0]['value_real'];
}
$price_to_apply_shipment = floatval($order_total) - floatval($total_discounts);
替换
//$check_delivery_price_by_price = Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $total_order, (int)$id_zone, (int)$this->id_currency);
by
$check_delivery_price_by_price = Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $price_to_apply_shipment, (int)$id_zone, (int)$this->id_currency);
并且
//$shipping_cost += $carrier->getDeliveryPriceByPrice($the_total_price, $id_zone, (int)$this->id_currency);
By
$shipping_cost += $carrier->getDeliveryPriceByPrice($price_to_apply_shipment, $id_zone, (int)$this->id_currency);
清除缓存并运行
我需要计算折扣后的运费
例如
总购物车:65$
免费送货开始:65$
折扣:5%
折扣后低于 65 美元仍然免费送货 我需要它来计算发货前的折扣
首先按运营商设置范围(0-65:X 欧元,65 以上:0 欧元)
覆盖 class Cart.php
Rewrite function getPackageShippingCost
行后
// Order total in default currency without fees
$order_total = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, $product_list);
添加这个
//Recalcul total pour panier et livraison gratuite
$listeDiscounts = $this->getCartRules();
$total_discounts = 0;
if (is_array($listeDiscounts)) {
if (isset($listeDiscounts[0]['value_real']))
$total_discounts = $listeDiscounts[0]['value_real'];
}
$price_to_apply_shipment = floatval($order_total) - floatval($total_discounts);
替换
//$check_delivery_price_by_price = Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $total_order, (int)$id_zone, (int)$this->id_currency);
by
$check_delivery_price_by_price = Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $price_to_apply_shipment, (int)$id_zone, (int)$this->id_currency);
并且
//$shipping_cost += $carrier->getDeliveryPriceByPrice($the_total_price, $id_zone, (int)$this->id_currency);
By
$shipping_cost += $carrier->getDeliveryPriceByPrice($price_to_apply_shipment, $id_zone, (int)$this->id_currency);
清除缓存并运行