【问题标题】:How can the attribute change when other attribute click in Prestashop 1.7?Prestashop 1.7 中点击其他属性时属性如何变化?
【发布时间】:2020-05-25 08:25:05
【问题描述】:

我是 prestashop 的初学者。单击属性时,我将更改其他属性。

例如,我店里有汽车产品,关于汽车的宽度有“2m”、“3m”、“4m”三个属性。

这辆车的价格是 500 美元。 “2m”属性将汽车产品的价格提高到2+USD。 “3m”属性将汽车产品的价格提高到3+USD。 “4m”属性将汽车产品的价格提高到4+美元。

现在,如果我点击“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.

【问题讨论】:

    标签: javascript php frameworks


    【解决方案1】:

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

    1. 创建新/编辑产品
    2. 在右侧,您会看到 组合 选择 ** Product with combination **
    3. 点击组合标签
    4. 为 2m、3m 和 4m 创建组合
    5. 您可以更改每种组合的价格

    希望对您有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-15
      • 2020-11-20
      相关资源
      最近更新 更多