【问题标题】:**Prestashop** - How to modify the product attributes <select> into radio box?**Prestashop** - 如何将产品属性 <select> 修改为单选框?
【发布时间】:2013-08-16 13:14:35
【问题描述】:

我想修改产品属性在我的产品页面上的显示方式。

默认情况下,属性以 html 标记显示。 我想用 html 表单显示这些属性并为我的属性添加描述。

到目前为止,我尝试的是修改 product.tpl 文件,并进行了以下更改:

<select name="{$groupName}" id="group_{$id_attribute_group|intval}" onchange="javascript:findCombination();{if $colors|@count > 0}$('#wrapResetImages').show('slow');{/if};">
                    {foreach from=$group.attributes key=id_attribute item=group_attribute}
                        <option value="{$id_attribute|intval}"{if (isset($smarty.get.$groupName) && $smarty.get.$groupName|intval == $id_attribute) || $group.default == $id_attribute} selected="selected"{/if} title="{$group_attribute|escape:'htmlall':'UTF-8'}">{$group_attribute|escape:'htmlall':'UTF-8'}</option>
                    {/foreach} </select>

进入

<form name="{$groupName}" id="group_{$id_attribute_group|intval}" onchange="javascript:findCombination();{if $colors|@count > 0}$('#wrapResetImages').show('slow');{/if};">
                    {foreach from=$group.attributes key=id_attribute item=group_attribute}
                        <input type="radio" name="test" value="{$id_attribute|intval}"{if (isset($smarty.get.$groupName) && $smarty.get.$groupName|intval == $id_attribute) || $group.default == $id_attribute} checked="checked"{/if} title="{$group_attribute|escape:'htmlall':'UTF-8'}">{$group_attribute|escape:'htmlall':'UTF-8'}
                    {/foreach} </form>

通过此修改,属性似乎不再与产品相关联,因为始终显示以下消息:“以下产品不适用于此属性...”。所以它不起作用,因为我不能再将产品添加到购物车并且属性不再影响价格......

您对使它正常工作的方法有任何线索吗? 您知道哪些文件与产品属性相关联吗? 是否需要修改 AdminAttributes.php 文件?

感谢大家的帮助

【问题讨论】:

  • 我不明白,你为什么需要Form??

标签: attributes smarty product prestashop field-description


【解决方案1】:

在 prestashop 1.4 中,您需要编辑 product.js。找到findCombination函数并编辑。

$('div#attributes select').each(function(){
    choice.push($(this).val());
});

作者:

$('div#attributes input[type=radio]:checked').each(function(){
    choice.push($(this).val());
});

product.tpl你需要修改文件

<ul>
{foreach from=$group.attributes key=id_attribute item=group_attribute}
<li>
    <input type="radio" class="attribute_radio" name="{$groupName}" value="{$id_attribute}" {if ($group.default == $id_attribute)} checked="checked"{/if} onclick="findCombination();getProductAttribute();" />
    <span>{$group_attribute|escape:'htmlall':'UTF-8'}</span>
</li>
{/foreach}
</ul>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-24
    相关资源
    最近更新 更多