How to add product images to order emails of admin and customer on Opencart 2.x
Posted: Sun Sep 10, 2017 8:39 am
Hi, I made some changes in
and
Here is my edits:
First, on order.php, around 548. line, under the code
I added:
After that, around 581, under the code
I added:
Finally, on order.tpl file, under the code
I added:
Everything is looking good. And also images are shown exactly how I wanted. However, if there are more than one order,then there is a problem: When I click the images, links are always the same as the first image. That's, my edits fetch the images but links.. What is wrong in my edits? Any answer would be appreciated.
Code: Select all
Model File : \catalog\model\checkout\order.php
Code: Select all
TPL File : \catalog\view\theme\journal2\template\mail\order.tpl
First, on order.php, around 548. line, under the code
Code: Select all
foreach ($order_product_query->rows as $product) {
$option_data = array();
I added:
Code: Select all
foreach ($order_product_query->rows as $order_product) {
$product_info = $this->model_catalog_product->getProduct($order_product['product_id']);
if ($product_info['image']) {
$thumbbuyuk = $this->model_tool_image->resize($product_info['image'], 130, 130);
} else {
$thumbbuyuk = '';
}
}
Code: Select all
$data['products'][] = array(
Code: Select all
'thumbbuyuk' => $thumbbuyuk,
'href' => $this->url->link('product/product', 'product_id=' .$product_info['product_id']),
Code: Select all
<p style="margin-top: 0px; margin-bottom: 20px;"><?php echo $text_greeting; ?></p>
Code: Select all
<div style="text-align:center;">
<?php foreach ($products as $product) { ?>
<?php if ($product['thumbbuyuk']) { ?>
<a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumbbuyuk']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" class="img-thumbnail" /></a>
<?php } ?>
<?php } ?>
</div>