Jump to content

How to add Product Image to Confirmation Email?


Recommended Posts

Hello,

I was wondering how to add images to product confirmation email on version 1.6.1.7? 

Adding the code below to classes/PaymentModule.php doesn't seem to be working

$cover = Image::getCover((int)$product['id_product']); // array image
if (sizeof($cover['id_image']) > 0) {
	$folder = Image::getImgFolderStatic($cover['id_image']);  // folders inside /img/p/
	$image = '<img src="../img/p/'.$folder.$cover['id_image'].'-medium_default.jpg" alt="" width="125" height="125" class="imgm img-thumbnail" />';
} else {
	$image = '<img src="../img/p/en-default-medium_default.jpg" alt="" width="125" height="125" class="imgm img-thumbnail" />';
}

$product_var_tpl = array(
	'reference' => $product['reference'],
	'image' => $image,
	'name' => $product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : ''),
	'unit_price' => Tools::displayPrice($product_price, $this->context->currency, false),
	'price' => Tools::displayPrice($product_price * $product['quantity'], $this->context->currency, false),
	'quantity' => $product['quantity'],
	'customization' => array()
);

 

Than I added {$product['image']} to the order_conf.html but nothing showed.

What do you suggest I do?

Edited by Dove99x (see edit history)

Share this post


Link to post
Share on other sites

Thank you for the reply @NemoPS -  I really appreciate it. maybe I'm doing it wrong, but I've updated the "order_conf_product_list.tpl" with the code <img src="{$this->context->link->getImageLink}"> but it is not showing anything for me. 

Do I need to do anything extra as I've removed all changes to  classes/PaymentModule.php

Share this post


Link to post
Share on other sites
  • 1 year later...

We can have a better solution, without override or modify PaymentModule.php

so Mail.php send an Array for product. We only 6 keys, but we have the id product. It's alll we need for the tpl;

smarty var for url img cannot work because product in Mail is a simple Array, but we not need img with the url rewrite inside an email. 

and in htaccess we can find line like this

RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg [L]

 

order_conf_product_list.tpl 

{foreach $list as $product}
     {assign var='defaultImage' value=Product::getCover($product['id_product'])}   // we have now the ID image

	 //// tr, td etc....
	<img src="DOMAINNAME/{$defaultImage['id_image']}-medium_THEMENAME/{$defaultImage['id_image']}-medium_default.jpg"  width="110" height="120"/>	

	//// replace DOMAINENAME by https://www.yourdomaine
	//// replace THEMENAME by your name theme

	//// tr, td etc....
{/foreach}

		

this code work because all image name is  related to id and the rewrite inside default htaccess work well.

and if you look in ftp you see for id 40  : 

  • p/4/0   =>  40-small_default.jpg, 40-medium_default.jpg,40-large_default.jpg, etc......
Edited by david_caribou (see edit history)
  • Thanks 2

Share this post


Link to post
Share on other sites
  • 3 weeks later...
On 26/8/2019 at 11:56 AM, david_caribou dice:

this code work because all image name is  related to id and the rewrite inside default htaccess work well.

Hello david_caribou, this is supposed to works also on PS1.7?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More