Merge pull request #937 from PhpMadman/DiscountPrice

[*] FO : Added possibility to display new price instead of quantity discount
This commit is contained in:
Jérôme Nadaud
2013-11-06 08:06:16 -08:00
2 changed files with 45 additions and 29 deletions
@@ -180,7 +180,15 @@ class AdminPPreferencesControllerCore extends AdminController
'validation' => 'isBool', 'validation' => 'isBool',
'cast' => 'intval', 'cast' => 'intval',
'type' => 'bool' 'type' => 'bool'
) ),
'PS_DISPLAY_DISCOUNT_PRICE' => array(
'title' => $this->l('Display discounted price'),
'desc' => $this->l('Insted of showing the discount (-5%) it will instead show the new price with the discount applied'),
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool'
),
) )
), ),
'stock' => array( 'stock' => array(
+36 -28
View File
@@ -459,34 +459,42 @@ var fieldRequired = '{l s='Please fill in all the required fields before saving
</ul> </ul>
<div id="quantityDiscount"> <div id="quantityDiscount">
<table class="std"> <table class="std">
<thead> <thead>
<tr> <tr>
<th>{l s='Product'}</th> <th>{l s='Product'}</th>
<th>{l s='From (qty)'}</th> <th>{l s='From (qty)'}</th>
<th>{l s='Discount'}</th> <th>{if Configuration::get('PS_DISPLAY_DISCOUNT_PRICE')}{l s='Price'}{else}{l s='Discount'}{/if}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{foreach from=$quantity_discounts item='quantity_discount' name='quantity_discounts'} {foreach from=$quantity_discounts item='quantity_discount' name='quantity_discounts'}
<tr id="quantityDiscount_{$quantity_discount.id_product_attribute}" class="quantityDiscount_{$quantity_discount.id_product_attribute}"> <tr id="quantityDiscount_{$quantity_discount.id_product_attribute}" class="quantityDiscount_{$quantity_discount.id_product_attribute}">
<td> <td>
{if (isset($quantity_discount.attributes) && ($quantity_discount.attributes))} {if (isset($quantity_discount.attributes) && ($quantity_discount.attributes))}
{$product->getProductName($quantity_discount.id_product, $quantity_discount.id_product_attribute)} {$product->getProductName($quantity_discount.id_product, $quantity_discount.id_product_attribute)}
{else} {else}
{$product->getProductName($quantity_discount.id_product)} {$product->getProductName($quantity_discount.id_product)}
{/if} {/if}
</td> </td>
<td>{$quantity_discount.quantity|intval}</td> <td>{$quantity_discount.quantity|intval}</td>
<td> <td>
{if $quantity_discount.price >= 0 OR $quantity_discount.reduction_type == 'amount'} {if $quantity_discount.price >= 0 OR $quantity_discount.reduction_type == 'amount'}
-{convertPrice price=$quantity_discount.real_value|floatval} {if Configuration::get('PS_DISPLAY_DISCOUNT_PRICE')}
{else} {convertPrice price=$productPrice-$quantity_discount.real_value|floatval}
-{$quantity_discount.real_value|floatval}% {else}
{/if} -{convertPrice price=$quantity_discount.real_value|floatval}
</td> {/if}
</tr> {else}
{/foreach} {if Configuration::get('PS_DISPLAY_DISCOUNT_PRICE')}
</tbody> {convertPrice price = $productPrice-($productPrice*$quantity_discount.reduction)|floatval}
{else}
-{$quantity_discount.real_value|floatval}%
{/if}
{/if}
</td>
</tr>
{/foreach}
</tbody>
</table> </table>
</div> </div>
{/if} {/if}