首页 > 解决方案 > 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.

标签: javascriptphpframeworks

解决方案


您可以使用 prestashop 的“组合”功能

  1. 创建新/编辑产品
  2. 在右侧,您会看到组合选择 ** 具有组合的产品 **
  3. 单击组合选项卡
  4. 为 2m、3m 和 4m 创建组合
  5. 您可以更改每个组合的价格

希望这对你有帮助!


推荐阅读