javascript - Prestashop 1.7 中点击其他属性时属性如何变化?
问题描述
我是prestashop的初学者。单击属性时,我将更改其他属性。
比如我店里有汽车产品,关于汽车的宽度有“2m”、“3m”、“4m”三个属性。
这辆车的价格是500美元。“2m”属性将汽车产品的价格提高到2+USD。“3m”属性将汽车产品的价格提高到3+USD。“4m”属性将汽车产品的价格提高到4+USD。
现在,如果我点击“3m”属性,汽车的总价格将是 503 美元,“2m”和“3m”属性的价格没有改变。我想更改另一个属性的价格。例如,当我单击“3m”属性时,“2m”和“3m”属性的价格应更改为“-1”和“+1”。
最后,我想更改其他属性的价格期望我单击的属性。我可以在 Prestashop 管理页面上完成这些项目吗?我在那儿找不到线索。所以我开始在我的 FTP 服务器中编写 PHP 或 tpl 代码。我不知道我必须写在控制器或tpl文件中。我将在 tpl 文件中编写代码。那么实施这一点是正确的吗?
代码下方。
{foreach from=$group.attributes key=id_attribute item=group_attribute}
<li class="input-container" title="{$group_attribute.name} - {$group.name}">
<input class="input-radio attri" 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 isset($ahpvarsaver) && $ahpvarsaver && $group_attribute.price > 0}
{if $product.discount_type === 'percentage'}
{$ta=$product.discount_percentage/100}
{$tas=str_replace("-","",$ta)}
{$tass=str_replace("%","",$tas)}
<span style="text-align:center;display:none" class="iprice {$ta} {$tas} {$tass}" con="{$group_attribute.price}"> <center>
{$foo=$group_attribute.price-$group_attribute.price*$tass}
{$num=number_format((float)$foo, 2, '.', '')}
{l s='+%1$s' sprintf=[Tools::displayPrice($num)]}
</center>
</span>
{else}
<span style="text-align:center;" class="iprice " con="{$group_attribute.price}"><center>
{l s='+%1$s' sprintf=[Tools::displayPrice($group_attribute.price)]}
</center></span>
{/if}
{/if}
<span class="st-input-loading"><i class="fto-spin5 animate-spin"></i></span>
</li>
{/foreach}
{*/foreach*}
Please answer my question in more detail. Thanks.
解决方案
您可以使用 prestashop 的“组合”功能
- 创建新/编辑产品
- 在右侧,您会看到组合选择 ** 具有组合的产品 **
- 单击组合选项卡
- 为 2m、3m 和 4m 创建组合
- 您可以更改每个组合的价格
希望这对你有帮助!
推荐阅读
- java - 在java中返回有一些问题
- mysql - 使用 sinon 对带有回调的 mysql 查询进行单元测试
- c - 警告:格式 '%s' 需要匹配的 'char *' 参数 [-Wformat=]
- python - 在 Python Flatten() 中展平列表列表不起作用 可能的生成器问题
- c# - 为什么要更改 file2 的状态,file1 在 VSTO 中添加 word 的 Ribbon 也会更改
- c - 为什么我的 printf 不能接收我的用户输入?
- android - 无法正确配置 expo 应用程序`无法读取配置:/app.config.js`
- html - 如何计算 C++ 中的 HTML 标签?
- unity3d - 2DLights - 通用渲染管线 - 轻量级 RP
- docker - docker-compose 端口未映射;日志显示应用程序正在运行