【问题标题】:Show product features in cart summary in Prestashop在 Prestashop 的购物车摘要中显示产品功能
【发布时间】:2016-11-07 16:44:34
【问题描述】:

我正在尝试使用shopping-cart-product-line.tpl 中的以下代码在一页结帐的购物车摘要中显示产品功能,但出现错误。

{foreach from=$product.features item=feature name=features}
{if $feature.id_feature == 9}   
{$features.value|escape:'htmlall':'UTF-8'}
{/if} 
{/foreach}

我需要对CartController.php 做任何事情吗?

错误 注意:未定义的索引:值在 path/tools/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d 代码在第 89 行

【问题讨论】:

  • 你能添加错误信息吗?

标签: php html mysql prestashop


【解决方案1】:

应该是{$feature.value} 而不是{$features.value}

{foreach from=$product.features item=feature name=features}
{if $feature.id_feature == 9}   
{$feature.value|escape:'htmlall':'UTF-8'}
{/if} 
{/foreach}

无需重写控制器或类。

【讨论】:

    【解决方案2】:

    试试这个方法

    {assign var="features" value=Product::getFrontFeaturesStatic(Context::getContext()->language->id, $product.id_product)} 
    
    {foreach $features as $feature}
    {if $feature.id_feature == 6}
    <div>{$feature.value|escape:'htmlall':'UTF-8'}</div>
    {/if}
    
    {/foreach}
    

    【讨论】:

      【解决方案3】:

      您需要通过修改以下文件之一中的代码来分配功能值(这取决于您在商店中使用的结帐类型):

      /controllers/front/OrderOpcController.php (Edit for OPC)
      

      /controllers/front/OrderController.php (Edit for five step)
      

      $features 数组中缺少“value”字段,您可以使用以下函数获取任何产品的特征数据。

       Product::getFeaturesStatic($id_product);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-11-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-05-02
        • 1970-01-01
        • 2013-06-07
        相关资源
        最近更新 更多