【问题标题】:Add features to Prestashop email order confirmation向 Prestashop 电子邮件订单确认添加功能
【发布时间】:2017-12-15 22:03:30
【问题描述】:

我想在 Prestashop 中将产品功能添加到发送给客户的订单确认中。

在这种情况下,我们有 1.6.1.4 类/PaymentModule.php 文件,它向我们显示 产品名称 - 属性:属性值,例如 Nice Nike 鞋 - 尺寸:42强>.

我想扩展它以显示:

漂亮的耐克鞋 - 尺码:42

系列:Hyperdunk(作为特征系列和特征值Hyperdunk)

 'name' => $product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : ''),

所以我想添加新的模板变量,比如

  'features' => $product['features'].(isset($product['features']) ? ' - '.$product['features'] : ''),

我也在 order_conf_product_list.tpl 中添加了

<td style="border:1px solid #D6D4D4;">
    <table class="table">
        <tr>
            <td width="10">&nbsp;</td>
            <td>
                <font size="2" face="Open-sans, sans-serif" color="#555454">
                    <strong>{$product['name']}</strong><br />{$product['features']} 
                </font>
            </td>
            <td width="10">&nbsp;</td>
        </tr>
    </table>
</td>

但它不起作用......有什么想法吗?

编辑:启用调试模式后,我有 Array - Array 代替 {$product['features']} 变量

【问题讨论】:

    标签: php prestashop prestashop-1.6


    【解决方案1】:

    首先,您在 PaymentModule 中的更改不正确。 $product['features'] 只包含一个带有id_featureid_productid_feature_value 的数组。 在分配给 tpl 之前,您需要获取功能名称和值:

    $features = "";
    if($product_features = Product::getFrontFeaturesStatic($order->id_lang, $product['id_product'])){
         foreach($product_features as $f){
              $features .= $f['name'] . " - " . $f['value'];
         }
    }
    

    然后将其分配给模板

    'features' => $features,
    

    或连接到产品名称。

    编辑(根据评论中的要求添加条件):

    使用以下代码:

    $features = "";
    if($product_features = Product::getFrontFeaturesStatic($order->id_lang, $product['id_product'])){
        foreach($product_features as $f){
             if(in_array($f['id_feature'], array(3, 5)))
                  $features .= $f['name'] . " - " . $f['value'];
        }
    }
    

    【讨论】:

    • 非常好!需要对名称稍作调整,但它可以工作!现在我看到一些产品有很多功能......你能帮助他们限制只显示选定的功能名称 id=3 和 id =5 吗?
    • 我已经编辑了我的答案并添加了仅在 id_feature 为 3 或 5 时才连接的条件。它会忽略其他人。
    • 完美!我几乎有这个解决方案。祝你有个愉快的一天! :)
    猜你喜欢
    • 2014-11-03
    • 1970-01-01
    • 2014-02-19
    • 2017-02-07
    • 1970-01-01
    • 1970-01-01
    • 2013-11-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多