首页 文章

Opencart产品图片订购确认电子邮件

提问于
浏览
1

我正在尝试将订购产品的图像显示在结帐后发送的客户订单确认邮件中 . 该电子邮件的内容位于order.tpl文件中,包含产品名称的$ product ['name'],产品型号的$ product ['model'] . 我不知道什么变量/数组包含产品图像或如何实现它 .

3 回答

  • 0

    是 . 你必须修改 model/checkout/order/addOrderHistory() 函数 . 请注意,任何订单的产品都是从 order_product 表中提取的 . 它不包含任何图像字段 . 为此,您必须创建一个功能,从 product 表中获取产品图像,然后处理该图像以进一步执行 .

    例如,在 catalog/model/order 文件中创建任何函数 . 喜欢...

    public function getProductImage($product_id){
        $query = $this->db->query("SELECT `image` FROM `".DB_PREFIX."product` WHERE product_id = '".(int)$product_id."'");
    
        if ($query->row) {
            return $query->row['image'];
        } else {
            return false;   
        }
    }
    

    foreach ($order_product_query->rows as $product) { 循环中调用此方法

    $product_image = $this->getProductImage($product['product_id']) .

    然后在同一个循环中通过检查调整图像大小

    $this->load->model('tool/image');
    
    if ($product_image) {
       $product_image = $this->model_tool_resize($product_image, width, height);
    }
    

    在你的产品阵列中添加这个,

    $data['products'][] = array(
     'image' => $product_image,
     .....
    );
    

    并在您的 .tpl 文件中检查

    if ($product['image']){
      your design to display image
    }
    

    而已 .

  • 3

    该电子邮件是从 model/checkout/order.php/addOrderHistory() 发送的 . 您必须在产品循环中添加图像 . 然后在 .tpl 文件中,您必须插入新列并在其中显示产品图像 .

  • 1

    您正在寻找的变量是图像使用它如下所示 .

    <?php echo $product['image']; ?>
    

    你可以在opencart网站上找到免费的扩展程序 .

相关问题