[*] PDF : Cart rules are now displayed as a "product line"

This commit is contained in:
fBrignoli
2012-05-11 09:17:54 +00:00
parent f7d087fbf6
commit 79b2993a8a
3 changed files with 33 additions and 9 deletions
+8 -4
View File
@@ -590,7 +590,10 @@ class CartRuleCore extends ObjectModel
} }
if ($countMatchingProducts < $productRuleGroup['quantity']) if ($countMatchingProducts < $productRuleGroup['quantity'])
return (!$display_error) ? false : Tools::displayError('You cannot use this voucher with these products'); return (!$display_error) ? false : Tools::displayError('You cannot use this voucher with these products');
// p($matchingProductsList);
// p($eligibleProductsList);
$eligibleProductsList = CartRule::array_uintersect($eligibleProductsList, $matchingProductsList); $eligibleProductsList = CartRule::array_uintersect($eligibleProductsList, $matchingProductsList);
// d($eligibleProductsList);
break; break;
case 'categories': case 'categories':
$cartCategories = Db::getInstance()->executeS(' $cartCategories = Db::getInstance()->executeS('
@@ -662,7 +665,7 @@ class CartRuleCore extends ObjectModel
return $selectedProducts; return $selectedProducts;
return (!$display_error) ? true : false; return (!$display_error) ? true : false;
} }
protected static function array_uintersect($array1, $array2) protected static function array_uintersect($array1, $array2)
{ {
$intersection = array(); $intersection = array();
@@ -675,7 +678,7 @@ class CartRuleCore extends ObjectModel
} }
return $intersection; return $intersection;
} }
protected static function array_uintersect_compare($a, $b) protected static function array_uintersect_compare($a, $b)
{ {
if ($a == $b) if ($a == $b)
@@ -1008,7 +1011,7 @@ class CartRuleCore extends ObjectModel
WHERE id_cart = '.(int)$context->cart->id.' WHERE id_cart = '.(int)$context->cart->id.'
AND id_cart_rule = '.(int)$cartRule->id)) AND id_cart_rule = '.(int)$cartRule->id))
$context->cart->removeCartRule($cartRule->id); $context->cart->removeCartRule($cartRule->id);
foreach ($cartRules as $cartRule) foreach ($cartRules as $cartRule)
if ($cartRule->checkValidity($context, true, false)) if ($cartRule->checkValidity($context, true, false))
$context->cart->addCartRule($cartRule->id); $context->cart->addCartRule($cartRule->id);
@@ -1038,4 +1041,5 @@ class CartRuleCore extends ObjectModel
WHERE code LIKE \'%'.pSQL($name).'%\' WHERE code LIKE \'%'.pSQL($name).'%\'
'); ');
} }
} }
+1
View File
@@ -70,6 +70,7 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
$this->smarty->assign(array( $this->smarty->assign(array(
'order' => $this->order, 'order' => $this->order,
'order_details' => $this->order_invoice->getProducts(), 'order_details' => $this->order_invoice->getProducts(),
'cart_rules' => $this->order->getCartRules($this->order_invoice->id),
'delivery_address' => $formatted_delivery_address, 'delivery_address' => $formatted_delivery_address,
'invoice_address' => $formatted_invoice_address, 'invoice_address' => $formatted_invoice_address,
'tax_excluded_display' => Group::getPriceDisplayMethod($customer->id_default_group), 'tax_excluded_display' => Group::getPriceDisplayMethod($customer->id_default_group),
+24 -5
View File
@@ -50,6 +50,7 @@
{else} {else}
<table style="width: 100%"> <table style="width: 100%">
<tr> <tr>
<td style="width: 50%"> <td style="width: 50%">
<span style="font-weight: bold; font-size: 10pt; color: #9E9F9E">{l s='Billing & Delivery Address.' pdf='true'}</span><br /> <span style="font-weight: bold; font-size: 10pt; color: #9E9F9E">{l s='Billing & Delivery Address.' pdf='true'}</span><br />
{$invoice_address} {$invoice_address}
@@ -107,6 +108,7 @@
<td style="background-color: #4D4D4D; color: #FFF; text-align: center; font-weight: bold; width: 10%">{l s='Qty' pdf='true'}</td> <td style="background-color: #4D4D4D; color: #FFF; text-align: center; font-weight: bold; width: 10%">{l s='Qty' pdf='true'}</td>
<td style="background-color: #4D4D4D; color: #FFF; text-align: right; font-weight: bold;; width: 15%">{l s='Total' pdf='true'}</td> <td style="background-color: #4D4D4D; color: #FFF; text-align: right; font-weight: bold;; width: 15%">{l s='Total' pdf='true'}</td>
</tr> </tr>
<!-- PRODUCTS -->
{foreach $order_details as $order_detail} {foreach $order_details as $order_detail}
{cycle values='#FFF,#DDD' assign=bgcolor} {cycle values='#FFF,#DDD' assign=bgcolor}
<tr style="line-height:6px;background-color:{$bgcolor};"> <tr style="line-height:6px;background-color:{$bgcolor};">
@@ -165,6 +167,23 @@
{/foreach} {/foreach}
{/foreach} {/foreach}
{/foreach} {/foreach}
<!-- END PRODUCTS -->
<!-- CART RULES -->
{foreach $cart_rules as $cart_rule}
{cycle values='#FFF,#DDD' assign=bgcolor}
<tr style="line-height:6px;background-color:{$bgcolor};" text-align="left">
<td colspan="{if !$tax_excluded_display}5{else}4{/if}">{$cart_rule.name}</td>
<td>
{if $tax_excluded_display}
- {$cart_rule.value_tax_excl}
{else}
- {$cart_rule.value}
{/if}
</td>
</tr>
{/foreach}
<!-- END CART RULES -->
</table> </table>
<table style="width: 100%"> <table style="width: 100%">
@@ -209,11 +228,11 @@
<tr style="line-height:5px;"> <tr style="line-height:5px;">
<td style="text-align: right; font-weight: bold">{l s='Shipping Cost' pdf='true'}</td> <td style="text-align: right; font-weight: bold">{l s='Shipping Cost' pdf='true'}</td>
<td style="width: 15%; text-align: right;"> <td style="width: 15%; text-align: right;">
{if $tax_excluded_display} {if $tax_excluded_display}
{displayPrice currency=$order->id_currency price=$order_invoice->total_shipping_tax_excl} {displayPrice currency=$order->id_currency price=$order_invoice->total_shipping_tax_excl}
{else} {else}
{displayPrice currency=$order->id_currency price=$order_invoice->total_shipping_tax_incl} {displayPrice currency=$order->id_currency price=$order_invoice->total_shipping_tax_incl}
{/if} {/if}
</td> </td>
</tr> </tr>
{/if} {/if}