问题
I am using prestashop 1.6. My site is offering "free shipping" for purchases over 80 bucks. My site is also having a promotion of "Buy 1 get 1 free".
Now, one item can cost about 60 bucks and I insisted the customer to buy 2 products from the same category in order to be entitled for buy 1 get 1.
If a customer buys one product, it should cost 60 bucks (no free shipping because final price < 80)
If a customer buys 2 = 120 bucks but after the "buy 1 get 1 free" promotion, the final total price is 60. So by right, this customer is not getting free shipping but my site gives free shipping to this customer because the "free shipping" logic is based on the total price before discounted (120 bucks).
How do I resolve this? I want the free shipping calculation to be based on the final total price (after discounted)

回答1:
You will have to override method getPackageShippingCost()
from Cart.php
.
And change those lines:
} else {
if ($shipping_method == Carrier::SHIPPING_METHOD_WEIGHT) {
$shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), $id_zone);
} else { // by price
$shipping_cost += $carrier->getDeliveryPriceByPrice($order_total, $id_zone, (int)$this->id_currency);
}
}
} else {
if ($shipping_method == Carrier::SHIPPING_METHOD_WEIGHT) {
$shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), $id_zone);
} else {
$shipping_cost += $carrier->getDeliveryPriceByPrice($order_total, $id_zone, (int)$this->id_currency);
}
}
by replacing $order_total
to $orderTotalwithDiscounts
:
} else {
if ($shipping_method == Carrier::SHIPPING_METHOD_WEIGHT) {
$shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), $id_zone);
} else { // by price
$shipping_cost += $carrier->getDeliveryPriceByPrice($orderTotalwithDiscounts, $id_zone, (int)$this->id_currency);
}
}
} else {
if ($shipping_method == Carrier::SHIPPING_METHOD_WEIGHT) {
$shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), $id_zone);
} else {
$shipping_cost += $carrier->getDeliveryPriceByPrice($orderTotalwithDiscounts, $id_zone, (int)$this->id_currency);
}
}
If you don't know how to override a class, please have a look at this documentation.
来源:https://stackoverflow.com/questions/37575809/prestashop-1-6-free-shipping-based-on-final-total-price