// Voucher cleaning
This commit is contained in:
+19
-12
@@ -1331,6 +1331,9 @@ class CartCore extends ObjectModel
|
||||
else
|
||||
$shipping_fees = 0;
|
||||
|
||||
if ($type == Cart::ONLY_SHIPPING)
|
||||
return $shipping_fees;
|
||||
|
||||
if ($type == Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING)
|
||||
$type = Cart::ONLY_PRODUCTS;
|
||||
|
||||
@@ -1455,6 +1458,8 @@ class CartCore extends ObjectModel
|
||||
$wrapping_fees = 0;
|
||||
if ($this->gift)
|
||||
$wrapping_fees = Tools::convertPrice(Tools::ps_round($this->getGiftWrappingPrice($with_taxes), 2), Currency::getCurrencyInstance((int)$this->id_currency));
|
||||
if ($type == Cart::ONLY_WRAPPING)
|
||||
return $wrapping_fees;
|
||||
|
||||
$order_total_discount = 0;
|
||||
if (!in_array($type, array(Cart::ONLY_SHIPPING, Cart::ONLY_PRODUCTS)) && CartRule::isFeatureActive())
|
||||
@@ -1512,12 +1517,6 @@ class CartCore extends ObjectModel
|
||||
$order_total -= $order_total_discount;
|
||||
}
|
||||
|
||||
if ($type == Cart::ONLY_SHIPPING)
|
||||
return $shipping_fees;
|
||||
|
||||
if ($type == Cart::ONLY_WRAPPING)
|
||||
return $wrapping_fees;
|
||||
|
||||
if ($type == Cart::BOTH)
|
||||
$order_total += $shipping_fees + $wrapping_fees;
|
||||
|
||||
@@ -2861,14 +2860,22 @@ 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'] && (empty($cart_rule['code']) || preg_match('/^'.CartRule::BO_ORDER_CODE_PREFIX.'[0-9]+/', $cart_rule['code'])))
|
||||
if ($cart_rule['free_shipping'])
|
||||
{
|
||||
$cart_rule['value_real'] -= $total_shipping;
|
||||
$cart_rule['value_tax_exc'] = $total_shipping_tax_exc;
|
||||
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;
|
||||
|
||||
// Update total shipping
|
||||
$total_shipping = 0;
|
||||
$total_shipping_tax_exc = 0;
|
||||
// Update total shipping
|
||||
$total_shipping = 0;
|
||||
$total_shipping_tax_exc = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$total_discounts += $total_shipping;
|
||||
$total_discounts_tax_exc += $total_shipping_tax_exc;
|
||||
}
|
||||
}
|
||||
if ($cart_rule['gift_product'])
|
||||
{
|
||||
|
||||
@@ -864,7 +864,15 @@ class CartRuleCore extends ObjectModel
|
||||
|
||||
// If it has the same tax application that you need, then it's the right value, whatever the product!
|
||||
if ($this->reduction_tax == $use_tax)
|
||||
{
|
||||
// The reduction cannot exceed the products total, except when we do not want it to be limited (for the partial use calculation)
|
||||
if ($filter != CartRule::FILTER_ACTION_ALL_NOCAP)
|
||||
{
|
||||
$cart_amount = $context->cart->getOrderTotal($use_tax, Cart::ONLY_PRODUCTS);
|
||||
$reduction_amount = min($reduction_amount, $cart_amount);
|
||||
}
|
||||
$reduction_value += $prorata * $reduction_amount;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->reduction_product > 0)
|
||||
|
||||
@@ -100,23 +100,6 @@
|
||||
<td colspan="2" class="price" id="total_product">{displayPrice price=$total_products}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
<tr class="cart_total_voucher" {if $total_discounts == 0}style="display:none"{/if}>
|
||||
<td colspan="5">
|
||||
{if $use_taxes && $display_tax_label}
|
||||
{l s='Total vouchers (tax excl.):'}
|
||||
{else}
|
||||
{l s='Total vouchers:'}
|
||||
{/if}
|
||||
</td>
|
||||
<td colspan="2" class="price-discount price" id="total_discount">
|
||||
{if $use_taxes && !$priceDisplay}
|
||||
{assign var='total_discounts_negative' value=$total_discounts * -1}
|
||||
{else}
|
||||
{assign var='total_discounts_negative' value=$total_discounts_tax_exc * -1}
|
||||
{/if}
|
||||
{displayPrice price=$total_discounts_negative}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="cart_total_voucher" {if $total_wrapping == 0}style="display: none;"{/if}>
|
||||
<td colspan="5">
|
||||
{if $use_taxes}
|
||||
@@ -162,6 +145,27 @@
|
||||
</tr>
|
||||
{/if}
|
||||
{/if}
|
||||
<tr class="cart_total_voucher" {if $total_discounts == 0}style="display:none"{/if}>
|
||||
<td colspan="5">
|
||||
{if $display_tax_label}
|
||||
{if $use_taxes && $priceDisplay == 0}
|
||||
{l s='Total vouchers (tax incl.):'}
|
||||
{else}
|
||||
{l s='Total vouchers (tax excl.):'}
|
||||
{/if}
|
||||
{else}
|
||||
{l s='Total vouchers:'}
|
||||
{/if}
|
||||
</td>
|
||||
<td colspan="2" class="price-discount price" id="total_discount">
|
||||
{if $use_taxes}
|
||||
{assign var='total_discounts_negative' value=$total_discounts * -1}
|
||||
{else}
|
||||
{assign var='total_discounts_negative' value=$total_discounts_tax_exc * -1}
|
||||
{/if}
|
||||
{displayPrice price=$total_discounts_negative}
|
||||
</td>
|
||||
</tr>
|
||||
{if $use_taxes}
|
||||
<tr class="cart_total_price">
|
||||
<td colspan="5">{l s='Total (tax excl.):'}</td>
|
||||
|
||||
Reference in New Issue
Block a user