Jump to content
thirty bees forum
  • 0

Product image in order conf email


Guido Buldrighini

Question

6 answers to this question

Recommended Posts

  • 0
26 minutes ago, Guido Buldrighini said:

Hi, is it possible to show product image in order conf email?

I find this but it doesn't work:
https://www.prestashop.com/forums/topic/229948-how-to-put-product-images-in-customer-order-mail/?tab=comments#comment-2089340

Of course it's possible. You need to 

1) edit file /classes/module/PaymentModule.php

and change lines

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

to look like this:

                        $productVarTpl = [
                            'id_product' => (int)$product['id_product'],
                            'id_product_attribute' => $product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null,
                            'id_image' => $product['id_image'],
                            'link_rewrite' => $product['link_rewrite'],
                            'reference' => $product['reference'],
                            'name' => $product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : ''),
                            'unit_price' => Tools::displayPrice($productPrice, $this->context->currency, false),
                            'price' => Tools::displayPrice($productPrice * $product['quantity'], $this->context->currency, false),
                            'quantity' => $product['quantity'],
                            'customization' => [],
                        ];

That will pass additional data to the order_conf_product_list.tpl template

2) edit /mails/en/order_conf_product_list.tpl -- replace /en/ with iso code of your language

and add this code there, just after first <tr>:

	<td style="border:1px solid #D6D4D4;">
		<table class="table">
			<tr>
				<td width="10">&nbsp;</td>
				<td>
					<img src="{$link->getImageLink($product['link_rewrite'], $product['id_image'], 'cart')}" alt="{$product['name']}" />
				</td>
				<td width="10">&nbsp;</td>
			</tr>
		</table>
	</td>

note the 'cart' string in getImageLink function. This is the image type that will be used. You can change it to any image type that exists in your system. 'cart' or 'home' should work fine in most cases

3) edit /mails/en/order_conf.html

you will need to add new column header here, and also adjust table colspans. Put this code 

<th bgcolor="#f8f8f8" style="border:1px solid #D6D4D4;background-color: #fbfbfb;color: #333;font-family: Arial;font-size: 13px;padding: 10px;">Image</th>

just above

<th bgcolor="#f8f8f8" style="border:1px solid #D6D4D4;background-color: #fbfbfb;color: #333;font-family: Arial;font-size: 13px;padding: 10px;">Reference</th>

and replace two occurances of 

colspan="5"

with

colspan="6"

 

That should do the trick. Result looks something like this:

image.png.aca316b374033a29df0bc7451202bd43.png

  • Like 2
Link to comment
Share on other sites

  • 0
On 10/1/2020 at 9:58 AM, datakick said:

Of course it's possible. You need to 

1) edit file /classes/module/PaymentModule.php

and change lines


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

to look like this:


                        $productVarTpl = [
                            'id_product' => (int)$product['id_product'],
                            'id_product_attribute' => $product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null,
                            'id_image' => $product['id_image'],
                            'link_rewrite' => $product['link_rewrite'],
                            'reference' => $product['reference'],
                            'name' => $product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : ''),
                            'unit_price' => Tools::displayPrice($productPrice, $this->context->currency, false),
                            'price' => Tools::displayPrice($productPrice * $product['quantity'], $this->context->currency, false),
                            'quantity' => $product['quantity'],
                            'customization' => [],
                        ];

That will pass additional data to the order_conf_product_list.tpl template

2) edit /mails/en/order_conf_product_list.tpl -- replace /en/ with iso code of your language

and add this code there, just after first <tr>:


	<td style="border:1px solid #D6D4D4;">
		<table class="table">
			<tr>
				<td width="10">&nbsp;</td>
				<td>
					<img src="{$link->getImageLink($product['link_rewrite'], $product['id_image'], 'cart')}" alt="{$product['name']}" />
				</td>
				<td width="10">&nbsp;</td>
			</tr>
		</table>
	</td>

note the 'cart' string in getImageLink function. This is the image type that will be used. You can change it to any image type that exists in your system. 'cart' or 'home' should work fine in most cases

3) edit /mails/en/order_conf.html

you will need to add new column header here, and also adjust table colspans. Put this code 


<th bgcolor="#f8f8f8" style="border:1px solid #D6D4D4;background-color: #fbfbfb;color: #333;font-family: Arial;font-size: 13px;padding: 10px;">Image</th>

just above


<th bgcolor="#f8f8f8" style="border:1px solid #D6D4D4;background-color: #fbfbfb;color: #333;font-family: Arial;font-size: 13px;padding: 10px;">Reference</th>

and replace two occurances of 


colspan="5"

with


colspan="6"

 

That should do the trick. Result looks something like this:

image.png.aca316b374033a29df0bc7451202bd43.png

Gracias!!!!!!

Funciona perfecto TB11

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