Reputation: 527
I'm trying to make the images of ordered products appear in the customer order confirmation mail sent after checkout. The content of that email is in the order.tpl file and contains such things as $product['name'] for product name, $product['model'] for product model. I don't know what variable/array holds the product image or how to implement this.
Upvotes: 1
Views: 1838
Reputation: 1619
Yes. You have to modify model/checkout/order/addOrderHistory()
function. Please note that products of any order are fetched from order_product
table. And it doesn't contain any image field. To do so you have to create a functionality which fetches product image from the product
table and then process that image to do further.
For example, create any function in catalog/model/order
file. like...
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;
}
}
Call this method in foreach ($order_product_query->rows as $product) {
loop like
$product_image = $this->getProductImage($product['product_id'])
.
Then in the same loop resize the image by checking
$this->load->model('tool/image');
if ($product_image) {
$product_image = $this->model_tool_resize($product_image, width, height);
}
And in your product array just add this,
$data['products'][] = array(
'image' => $product_image,
.....
);
And in your .tpl
file check
if ($product['image']){
your design to display image
}
That's It.
Upvotes: 2
Reputation: 651
the variable you are looking for is image use it as below.
<?php echo $product['image']; ?>
you can find free extensions on opencart site.
Upvotes: 0
Reputation: 3875
The email is being sent from model/checkout/order.php/addOrderHistory()
. You will have to add your image in the product loop. Then in the .tpl
file, you will have to insert new column and display the product image inside it.
Upvotes: 1