[-] FO : Fixed voucher value when it exceeds the product total #PSCFV-7421

This commit is contained in:
Damien Metzger committed 2013-02-04 11:53:07 +01:00
1 parent 197778c91a
commit 9c3f58b6a2
3 files changed
+12 -8

No files matched your search

+8 -4
View File
@@ -31,6 +31,7 @@ class CartRuleCore extends ObjectModel
const FILTER_ACTION_SHIPPING = 2; const FILTER_ACTION_SHIPPING = 2;
const FILTER_ACTION_REDUCTION = 3; const FILTER_ACTION_REDUCTION = 3;
const FILTER_ACTION_GIFT = 4; const FILTER_ACTION_GIFT = 4;
const FILTER_ACTION_ALL_NOCAP = 5;
const BO_ORDER_CODE_PREFIX = 'BO_ORDER_'; const BO_ORDER_CODE_PREFIX = 'BO_ORDER_';
@@ -757,7 +758,7 @@ class CartRuleCore extends ObjectModel
return Cache::retrieve($cache_id); return Cache::retrieve($cache_id);
// Free shipping on selected carriers // Free shipping on selected carriers
if ($this->free_shipping && ($filter == CartRule::FILTER_ACTION_ALL || $filter == CartRule::FILTER_ACTION_SHIPPING)) if ($this->free_shipping && in_array($filter, array(CartRule::FILTER_ACTION_ALL, CartRule::FILTER_ACTION_ALL_NOCAP, CartRule::FILTER_ACTION_SHIPPING)))
{ {
if (!$this->carrier_restriction) if (!$this->carrier_restriction)
$reduction_value += $context->cart->getOrderTotal($use_tax, Cart::ONLY_SHIPPING, is_null($package) ? null : $package['products'], is_null($package) ? null : $package['id_carrier']); $reduction_value += $context->cart->getOrderTotal($use_tax, Cart::ONLY_SHIPPING, is_null($package) ? null : $package['products'], is_null($package) ? null : $package['id_carrier']);
@@ -775,7 +776,7 @@ class CartRuleCore extends ObjectModel
} }
} }
if ($filter == CartRule::FILTER_ACTION_ALL || $filter == CartRule::FILTER_ACTION_REDUCTION) if (in_array($filter, array(CartRule::FILTER_ACTION_ALL, CartRule::FILTER_ACTION_ALL_NOCAP, CartRule::FILTER_ACTION_REDUCTION)))
{ {
// Discount (%) on the whole order // Discount (%) on the whole order
if ($this->reduction_percent && $this->reduction_product == 0) if ($this->reduction_percent && $this->reduction_product == 0)
@@ -892,9 +893,12 @@ class CartRuleCore extends ObjectModel
// Discount (¤) on the whole order // Discount (¤) on the whole order
elseif ($this->reduction_product == 0) elseif ($this->reduction_product == 0)
{ {
// TODO : this should not use the prorata
$cart_amount_ti = $context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS); $cart_amount_ti = $context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS);
$cart_amount_te = $context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS); $cart_amount_te = $context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS);
// 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)
$reduction_amount = min($reduction_amount, $this->reduction_tax ? $cart_amount_ti : $cart_amount_te);
$cart_vat_amount = $cart_amount_ti - $cart_amount_te; $cart_vat_amount = $cart_amount_ti - $cart_amount_te;
@@ -919,7 +923,7 @@ class CartRuleCore extends ObjectModel
} }
// Free gift // Free gift
if ((int)$this->gift_product && ($filter == CartRule::FILTER_ACTION_ALL || $filter == CartRule::FILTER_ACTION_GIFT)) if ((int)$this->gift_product && in_array($filter, array(CartRule::FILTER_ACTION_ALL, CartRule::FILTER_ACTION_ALL_NOCAP, CartRule::FILTER_ACTION_GIFT)))
{ {
$id_address = (is_null($package) ? 0 : $package['id_address']); $id_address = (is_null($package) ? 0 : $package['id_address']);
foreach ($package_products as $product) foreach ($package_products as $product)
+2 -2
View File
@@ -406,8 +406,8 @@ abstract class PaymentModuleCore extends Module
{ {
$package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list); $package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list);
$values = array( $values = array(
'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL, $package), 'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package),
'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL, $package) 'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package)
); );
// If the reduction is not applicable to this order, then continue with the next one // If the reduction is not applicable to this order, then continue with the next one
+2 -2
View File
@@ -191,8 +191,8 @@
{assign var="shipping_discount_tax_incl" value="0"} {assign var="shipping_discount_tax_incl" value="0"}
{foreach $cart_rules as $cart_rule} {foreach $cart_rules as $cart_rule}
{cycle values='#FFF,#DDD' assign=bgcolor} {cycle values='#FFF,#DDD' assign=bgcolor}
<tr style="line-height:6px;background-color:{$bgcolor};" text-align="left"> <tr style="line-height:6px;background-color:{$bgcolor}" text-align="left">
<td style="line-height:3px; text-align: left; width: 60%; vertical-align: top" colspan="{if !$tax_excluded_display}3{else}2{/if}">{$cart_rule.name}</td> <td style="line-height:3px;text-align:left;width:60%;vertical-align:top" colspan="{if !$tax_excluded_display}5{else}4{/if}">{$cart_rule.name}</td>
<td> <td>
{if $cart_rule.free_shipping} {if $cart_rule.free_shipping}
{assign var="shipping_discount_tax_incl" value=$order_invoice->total_shipping_tax_incl} {assign var="shipping_discount_tax_incl" value=$order_invoice->total_shipping_tax_incl}