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)
Link to comment
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

Link to comment
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
Link to comment
Share on other sites

  • 3 weeks later...
  • 1 year later...

I just installed 1.7.7.5 most recent stable version and with this post's help was able to get my images back onto my order confirmation email.  Here is my code for that section if it should help another. It has my formatting but the code being implemented correctly should work.

 

order_conf_product_list.tpl

 

{foreach $list as $product}
 {assign var='defaultImage' value=Product::getCover($product['id_product'])}   


        <table class="table" width="100%" align="left">
            <tr>
                <td colspan="5" width="5">&nbsp;</td>
                <td colspan="5" align="left" colspan="5" style="margin-bottom: 20px; text-align: left;">

    
    <img src="https://motleymutt.com/shop/{$defaultImage['id_image']}-medium_default/{$defaultImage['id_image']}-medium_default.jpg"  width="150" height="150"/>    

                
                    <br>

                    <font size="2" face="Open-sans, sans-serif" color="#107fab">
                    <strong>{$product['name']}</strong>
                    </font>
                        
                        {*
                        {if count($product['customization']) == 1}
                            <br>
                            {foreach $product['customization'] as $customization}
                                {$customization['customization_text']}
                            {/foreach}
                        {/if}
                        

Edited by RoadToSuccess (see edit history)
Link to comment
Share on other sites

  • 4 weeks later...

I recently upgraded to PS1.7.7.5 so the customization has been removed.
Now I'm trying to add it again, but it seem not working anymore.

First of all I have a doubt about the correct path of "order_conf_product_list.tpl" file.
In found it in these folders:
/mails/_partials/
/mails/it/
/themes/TEMPLATE_NAME/mails/it/
/themes/TEMPLATE_NAME/mails/en/
 

Which is the correct file to be modified?

 

Link to comment
Share on other sites

  • 2 months later...

Good evening everyone, 

I have implemented the above and have the image not showing. The outline is, just not the needed image. I did try default and also the template I'm using.   Prestashop 1.7.7.1 is the version.

Is anyone using the above method with this? I am thinking the path might be different for the images. I also tried -home_default.jpg which is in the order confirmation page. 

Any help would be much appreciated. I have found that dozens of people have the same problem and want an image in the order email.  

 

 

Link to comment
Share on other sites

  • 1 year later...

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...