首先,我要为我的英语不好而道歉!
我的代码有问题。我正在使用Prestashop 1.7.3,并且我想在每个属性下显示对价格的影响。使用我的代码,如果产品增加了百分比折扣,则我在价格中显示了影响,但我的代码没有显示折扣后对价格的影响。
例如:
产品属性1 的基本价格为50.00USD,但该产品已添加特定折扣价-50%
产品属性2 对价格+ 4.00USD产生了影响,该价格等于= 54.00USD,但该属性还添加了特定折扣价-50%。在属性2下应显示+ 2.00USD,该值是从产品属性1的费用中得出的(50.00usd-50%= 25.00USD)+对属性2的价格产生的影响(54.00usd-50%= 27.00USD)
在属性2下使用我的代码显示+ 4.00USD,这是对50%折扣前价格的影响。
这是product-variants.tpl +我的代码的全部代码:
<div class="product-variants">{*important refresh*}
{foreach from=$groups key=id_attribute_group item=group}
<div class="clearfix product-variants-item">
<span class="control-label">{$group.name}</span>
{if $group.group_type == 'select'}
<select
class="form-control form-control-select"
id="group_{$id_attribute_group}"
data-product-attribute="{$id_attribute_group}"
name="group[{$id_attribute_group}]">
{foreach from=$group.attributes key=id_attribute item=group_attribute}
<option value="{$id_attribute}" title="{$group_attribute.name}"{if $group_attribute.selected} selected="selected"{/if}>{$group_attribute.name}</option>
{/foreach}
</select>
{elseif $group.group_type == 'color'}
<ul id="group_{$id_attribute_group}" class="clearfix li_fl">
{foreach from=$group.attributes key=id_attribute item=group_attribute}
<li class="input-container" title="{$group_attribute.name}">
<input class="input-color" type="radio" data-product-attribute="{$id_attribute_group}" name="group[{$id_attribute_group}]" value="{$id_attribute}"{if $group_attribute.selected} checked="checked"{/if}/>
<span class="color {if $group_attribute.texture}texture{/if}"
{if $group_attribute.html_color_code} style="background-color: {$group_attribute.html_color_code}" {/if}
{if $group_attribute.texture} style="background-image: url({$group_attribute.texture})" {/if}
><span class="sr-only">{$group_attribute.name}</span></span>
<span class="st-input-loading"><i class="fto-spin5 animate-spin"></i></span>
</li>
{/foreach}
</ul>
{elseif $group.group_type == 'radio'}
<ul id="group_{$id_attribute_group}" class="clearfix li_fl">
{foreach from=$groups key=id_attribute_group item=group}
{foreach from=$group.name_price key=id_attribute item=group_attribute}
<li class="input-container" title="{$group_attribute.name}">
<input class="input-radio" type="radio" data-product-attribute="{$id_attribute_group}" name="group[{$id_attribute_group}]" value="{$id_attribute}"{if $group_attribute.selected} checked="checked"{/if}/>
<span class="radio-label">{$group_attribute.name}</span>
{if $group_attribute.price > 0}
<span style="float:right;" class="iprice" con="{$group_attribute.price}">
+{$price+$group_attribute.price}.00 лв.</span>
{/if}
{if $group_attribute.price < 0}
<span style="float:right;" class="iprice" con="{$group_attribute.price}">
{$price+$group_attribute.price}.00 лв.</span>
{/if}
<span class="st-input-loading"><i class="fto-spin5 animate-spin"></i></span>
</li>
{/foreach}
{/foreach}
{foreach from=$group.attributes key=id_attribute item=group_attribute}
{/foreach}
</ul>
{/if}
</div>
{/foreach}
</div>