我在prestashop上有以下代码。我试图将{$ combination.price}减少20%。但最后更改阵列似乎不起作用?即{$ combination.price / 1.2)
任何人都可以帮助我,我如何能够以20%的价格回报价格?
{if isset($groups)}
// Combinations
{foreach from=$combinations key=idCombination item=combination}
var specific_price_combination = new Array();
var available_date = new Array();
specific_price_combination['reduction_percent'] = {if $combination.specific_price AND $combination.specific_price.reduction AND $combination.specific_price.reduction_type ==
'percentage'}{$combination.specific_price.reduction*100}{else}0{/if};
specific_price_combination['reduction_price'] = {if $combination.specific_price AND $combination.specific_price.reduction AND $combination.specific_price.reduction_type ==
'amount'}{$combination.specific_price.reduction}{else}0{/if};
specific_price_combination['price'] = {if $combination.specific_price AND $combination.specific_price.price}{$combination.specific_price.price}{else}0{/if};
specific_price_combination['reduction_type'] = '{if $combination.specific_price}{$combination.specific_price.reduction_type}{/if}';
specific_price_combination['id_product_attribute'] = {if $combination.specific_price}{$combination.specific_price.id_product_attribute|intval}{else}0{/if};
available_date['date'] = '{$combination.available_date}';
available_date['date_formatted'] = '{dateFormat date=$combination.available_date full=false}';
addCombination({$idCombination|intval}, new Array({$combination.list}), {$combination.quantity}, {$combination.price}, {$combination.ecotax}, {$combination.id_image},
'{$combination.reference|addslashes}', {$combination.unit_impact}, {$combination.minimal_quantity}, available_date, specific_price_combination);
{/foreach}
{/if}
答案 0 :(得分:0)
$price * 0.8
或$price - ( $price * 0.2 )
无论哪种方式,他们都有相同的最终结果。第一个是变量$ price乘以80%,即20%赤字的价格。第二个例子是变量$ price减去变量$ price乘以20%,假设你用你试图以20%赤字返回的实际变量替换$ price,价格减去价格的20%。