[-] Core : Fixed a lot of issue with free shipping vouchers #PSCFV-7325
This commit is contained in:
+8
-16
@@ -1465,7 +1465,7 @@ class CartCore extends ObjectModel
|
||||
if (!in_array($type, array(Cart::ONLY_SHIPPING, Cart::ONLY_PRODUCTS)) && CartRule::isFeatureActive())
|
||||
{
|
||||
// First, retrieve the cart rules associated to this "getOrderTotal"
|
||||
if ($with_shipping)
|
||||
if ($with_shipping || $type == Cart::ONLY_DISCOUNTS)
|
||||
$cart_rules = $this->getCartRules(CartRule::FILTER_ACTION_ALL);
|
||||
else
|
||||
{
|
||||
@@ -1491,7 +1491,7 @@ class CartCore extends ObjectModel
|
||||
foreach ($cart_rules as $cart_rule)
|
||||
{
|
||||
// If the cart rule offers free shipping, add the shipping cost
|
||||
if ($with_shipping && $cart_rule['obj']->free_shipping)
|
||||
if (($with_shipping || $type == Cart::ONLY_DISCOUNTS) && $cart_rule['obj']->free_shipping)
|
||||
$order_total_discount += Tools::ps_round($cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_SHIPPING, ($param_product ? $package : null), $use_cache), 2);
|
||||
|
||||
// If the cart rule is a free gift, then add the free gift value only if the gift is in this package
|
||||
@@ -2860,22 +2860,14 @@ class CartCore extends ObjectModel
|
||||
foreach ($cart_rules as &$cart_rule)
|
||||
{
|
||||
// If the cart rule is automatic (wihtout any code) and include free shipping, it should not be displayed as a cart rule but only set the shipping cost to 0
|
||||
if ($cart_rule['free_shipping'])
|
||||
if ($cart_rule['free_shipping'] && (empty($cart_rule['code']) || preg_match('/^'.CartRule::BO_ORDER_CODE_PREFIX.'[0-9]+/', $cart_rule['code'])))
|
||||
{
|
||||
if (empty($cart_rule['code']) || preg_match('/^'.CartRule::BO_ORDER_CODE_PREFIX.'[0-9]+/', $cart_rule['code']))
|
||||
{
|
||||
$cart_rule['value_real'] -= $total_shipping;
|
||||
$cart_rule['value_tax_exc'] = $total_shipping_tax_exc;
|
||||
$cart_rule['value_real'] -= $total_shipping;
|
||||
$cart_rule['value_tax_exc'] = $total_shipping_tax_exc;
|
||||
|
||||
// Update total shipping
|
||||
$total_shipping = 0;
|
||||
$total_shipping_tax_exc = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$total_discounts += $total_shipping;
|
||||
$total_discounts_tax_exc += $total_shipping_tax_exc;
|
||||
}
|
||||
// Update total shipping
|
||||
$total_shipping = 0;
|
||||
$total_shipping_tax_exc = 0;
|
||||
}
|
||||
if ($cart_rule['gift_product'])
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user