Jump to content

How To Put Product Images In Customer Order Mail


Recommended Posts

Hi,

 

I would like to ask how can I put the product image into the mail that is sent to the customer? (customer order).

 

By default the only info are given to the customer are Reference, Product, Quantity, Unit Price

 

I would like it to show the product image also (like in the shopping cart).

 

thanks in advance!

 

Regards,

JD

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...
  • 2 months later...
  • 1 month later...

Hope it will help by inserting product variables in order_conf.html under mail folder\\

 

<img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')}" height="{$homeSize.height}" width="{$homeSize.width}" alt="{$product.name|escape:html:'UTF-8'}" />

 

Hope it will help by inserting product variables in order_conf.html under mail folder\\

 

<img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')}" height="{$homeSize.height}" width="{$homeSize.width}" alt="{$product.name|escape:html:'UTF-8'}" />

Link to comment
Share on other sites

  • 2 weeks later...

you can get the url of the cover image by this code:

//GET IMAGE LINK
  $id_image = Product::getCover((int)$product['id_product']);
  if (sizeof($id_image) > 0) {
   $image = new Image($id_image['id_image']);
   $image_url = _PS_BASE_URL_._THEME_PROD_DIR_.$image->getExistingImgPath().".jpg";
  }

 

 

you have to paste it in classes/PaymentModule.php ,

 

before the creation of the "tr" of the product. then use $image_url where you want to show the image.

 

i did it like this:

 

//GET IMAGE LINK
  $id_image = Product::getCover((int)$product['id_product']);
  if (sizeof($id_image) > 0) {
   $image = new Image($id_image['id_image']);
   $image_url = _PS_BASE_URL_._THEME_PROD_DIR_.$image->getExistingImgPath().".jpg";
  }
  if (!$customization_quantity || (int)$product['cart_quantity'] > $customization_quantity)
   $products_list .=
   '<tr style="background-color: '.($key % 2 ? '#DDE2E6' : '#EBECEE').';">
	<td><img src="'.$image_url.'" width="100" height="100"/></td>
	<td style="padding: 0.6em 0.4em;width: 15%;">'.$product['reference'].'</td>
	<td style="padding: 0.6em 0.4em;width: 30%;"><strong>'.$product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : '').'</strong></td>
	<td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt, $this->context->currency, false).'</td>
	<td style="padding: 0.6em 0.4em; width: 15%;">'.((int)$product['cart_quantity'] - $customization_quantity).'</td>
	<td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(((int)$product['cart_quantity'] - $customization_quantity) * (Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt), $this->context->currency, false).'</td>
   </tr>';

 

 

PS VERSION: 1.5.3.1

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

  • 1 month later...

AT2 your solution works, You are marvellous. I applied this technique in mail order to show images and it worked smoothly.

Can u advise how can i show more components of prestashop i mean if i am to show whole featured products or viewed products in mail order then how to do it.

Thanks a lot in advance

Link to comment
Share on other sites

  • 3 weeks later...
  • 2 months later...

hi, i need to past all this into paymentmodule.php ?

//GET IMAGE LINK
     $id_image = Product::getCover((int)$product['id_product']);
     if (sizeof($id_image) > 0) {
     $image = new Image($id_image['id_image']);
     $image_url = _PS_BASE_URL_._THEME_PROD_DIR_.$image->getExistingImgPath().".jpg";
     }
     if (!$customization_quantity || (int)$product['cart_quantity'] > $customization_quantity)
     $products_list .=
     '<tr style="background-color: '.($key % 2 ? '#DDE2E6' : '#EBECEE').';">
        <td><img src="'.$image_url.'" width="100" height="100"/></td>
        <td style="padding: 0.6em 0.4em;width: 15%;">'.$product['reference'].'</td>
        <td style="padding: 0.6em 0.4em;width: 30%;"><strong>'.$product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : '').'</strong></td>
        <td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt, $this->context->currency, false).'</td>
        <td style="padding: 0.6em 0.4em; width: 15%;">'.((int)$product['cart_quantity'] - $customization_quantity).'</td>
        <td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(((int)$product['cart_quantity'] - $customization_quantity) * (Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt), $this->context->currency, false).'</td>
     </tr>';
Link to comment
Share on other sites

  • 10 months later...

you can get the url of the cover image by this code:

//GET IMAGE LINK
	  $id_image = Product::getCover((int)$product['id_product']);
	  if (sizeof($id_image) > 0) {
	   $image = new Image($id_image['id_image']);
	   $image_url = _PS_BASE_URL_._THEME_PROD_DIR_.$image->getExistingImgPath().".jpg";
	  }

you have to paste it in classes/PaymentModule.php ,

 

before the creation of the "tr" of the product. then use $image_url where you want to show the image.

 

i did it like this:

 

//GET IMAGE LINK
	  $id_image = Product::getCover((int)$product['id_product']);
	  if (sizeof($id_image) > 0) {
	   $image = new Image($id_image['id_image']);
	   $image_url = _PS_BASE_URL_._THEME_PROD_DIR_.$image->getExistingImgPath().".jpg";
	  }
	  if (!$customization_quantity || (int)$product['cart_quantity'] > $customization_quantity)
	   $products_list .=
	   '<tr style="background-color: '.($key % 2 ? '#DDE2E6' : '#EBECEE').';">
		<td><img src="'.$image_url.'" width="100" height="100"/></td>
		<td style="padding: 0.6em 0.4em;width: 15%;">'.$product['reference'].'</td>
		<td style="padding: 0.6em 0.4em;width: 30%;"><strong>'.$product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : '').'</strong></td>
		<td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt, $this->context->currency, false).'</td>
		<td style="padding: 0.6em 0.4em; width: 15%;">'.((int)$product['cart_quantity'] - $customization_quantity).'</td>
		<td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(((int)$product['cart_quantity'] - $customization_quantity) * (Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt), $this->context->currency, false).'</td>
	   </tr>';

PS VERSION: 1.5.3.1

 

May i ask

 

You need change file /modules/mailalerts/mailalerts.php

May I ask you how to add a link with customer's order in mail alerts module? Thank you in advance

Link to comment
Share on other sites

  • 8 months later...

Oh, did not see, i thought it was mail alert module.

 

For costumer email you need edit mails/en/order_conf_product_list.tpl  file for prestashop 1.6.0.14 >

 

But also in file PaymentModule.php prestashop pass varibles to this tamplate on line 495:

 

 

if (count($product_var_tpl_list) > 0)
{
$product_list_txt = $this->getEmailTemplateContent('order_conf_product_list.txt', Mail::TYPE_TEXT, $product_var_tpl_list);
$product_list_html = $this->getEmailTemplateContent('order_conf_product_list.tpl', Mail::TYPE_HTML, $product_var_tpl_list);
}
So if you need pass new variable into template you need do this in file Payment Module.php same way like other standard variables. Edited by Kerm (see edit history)
Link to comment
Share on other sites

Hello,

 

I put this in the order_conf_product_list.tpl file

	<td><img src="'.$image_url.'" width="100" height="100"/></td>

In the PaymentModule.php in /classes directory what code i have to add? This one?

//GET IMAGE LINK
	  $id_image = Product::getCover((int)$product['id_product']);
	  if (sizeof($id_image) > 0) {
	   $image = new Image($id_image['id_image']);
	   $image_url = _PS_BASE_URL_._THEME_PROD_DIR_.$image->getExistingImgPath().".jpg";
	  }

if so... where i have to put it? Cause i tried after the

$product_var_tpl_list = array();
					foreach ($order->product_list as $product)
					{

but is not working

 

Please help

Link to comment
Share on other sites

Why you do this without basic php knowledges?

Inside PaymentModule.php near line 453, you can find this code inside foreach():

 

$product_var_tpl = array(
	'reference' => $product['reference'],
	'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()
);

You need put your code before this code, and after pass new variable in template.

Like that:

$id_image = Product::getCover((int)$product['id_product']);
if (sizeof($id_image) > 0) {
	$image = new Image($id_image['id_image']);
	$image_url = _PS_BASE_URL_._THEME_PROD_DIR_.$image->getExistingImgPath().".jpg";
}

$product_var_tpl = array(
	'reference' => $product['reference'],
	'image_url' => $image_url,
	'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()
);

And after in template write where you want this: {$product['image_url']}
 

Link to comment
Share on other sites

Try this:

$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()
);

Inside template write this: {$product['image']} and you get full image tag with image url.

In code change "medium_default" on your image size type.

Also if product dont have image you will see default product image in mail template: en-default-medium_default.jpg, change "en" if you have different language.

 

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

Oh, did not see, i thought it was mail alert module.

 

For costumer email you need edit mails/en/order_conf_product_list.tpl  file for prestashop 1.6.0.14 >

 

But also in file PaymentModule.php prestashop pass varibles to this tamplate on line 495:

 

 

if (count($product_var_tpl_list) > 0)
{
$product_list_txt = $this->getEmailTemplateContent('order_conf_product_list.txt', Mail::TYPE_TEXT, $product_var_tpl_list);
$product_list_html = $this->getEmailTemplateContent('order_conf_product_list.tpl', Mail::TYPE_HTML, $product_var_tpl_list);
}
So if you need pass new variable into template you need do this in file Payment Module.php same way like other standard variables.

 

Would you please explain step by step? I am a little bit lost :)

 

Thanks

Link to comment
Share on other sites

Inside PaymentModule.php you can find this code inside foreach():
 

  $product_var_tpl = array(
    'reference' => $product['reference'],
    '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()
); You need put your code before this code, and after pass new variable in template.

You need put your code before this code, and after pass new variable in template.

 

like that:

$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()
);

and then inside template write this: 

{$product['image']}

and you get full image tag with image url.

In code change "medium_default" on your image size type.

Also if product don't have image you will see default product image in mail template: en-default-medium_default.jpg, change "en" if you have different language.

Link to comment
Share on other sites

Inside PaymentModule.php you can find this code inside foreach():

 

  $product_var_tpl = array(
    'reference' => $product['reference'],
    '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()
); You need put your code before this code, and after pass new variable in template.

You need put your code before this code, and after pass new variable in template.

 

like that:

$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()
);

and then inside template write this: 

{$product['image']}

and you get full image tag with image url.

In code change "medium_default" on your image size type.

 

Also if product don't have image you will see default product image in mail template: en-default-medium_default.jpg, change "en" if you have different language.

 

Inside what template and where?

Link to comment
Share on other sites

A small problem. I only get cover image. I don't get the right image for the combination products. Product with color black or white and cover image is black, if i buy white i still get image for black. How do i change this?

Link to comment
Share on other sites

A small problem. I only get cover image. I don't get the right image for the combination products. Product with color black or white and cover image is black, if i buy white i still get image for black. How do i change this?

 

Try this code, i test it work on 1.6.1:

if (isset($product['id_product_attribute'])){
$result_images = Product::_getAttributeImageAssociations($product['id_product_attribute']);
if (isset($result_images[0])){
$folder = Image::getImgFolderStatic($result_images[0]);  // folders inside /img/p/
$image = '<img src="../img/p/'.$folder.$result_images[0].'-medium_default.jpg" alt="" width="125" height="125" class="imgm img-thumbnail" />';
} else {
$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" />';
}
}
} else {
$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()
);
Edited by Kerm (see edit history)
Link to comment
Share on other sites

  • 2 months later...
  • 3 weeks later...

I made override file for easy setup and attach it to this message.

 

Upload this file in this dir:

 

\override\classes\PaymentModule.php

 

After delete this file: /cache/class_index.php

 

After you need edit your email template:

 

\mails\en\order_conf_product_list.tpl

 

Put this code:

 

	<td style="border:1px solid #D6D4D4;">
		<table class="table">
			<tr>
				<td width="10"> </td>
				<td>
					<font size="2" face="Open-sans, sans-serif" color="#555454">
						{$product['image']}
					</font>
				</td>
				<td width="10"> </td>
			</tr>
		</table>
	</td>

Before this code:

 

	<td style="border:1px solid #D6D4D4;">
		<table class="table">
			<tr>
				<td width="10"> </td>
				<td>
					<font size="2" face="Open-sans, sans-serif" color="#555454">
						{$product['reference']}
					</font>
				</td>
				<td width="10"> </td>
			</tr>
		</table>
	</td>

Also edit \mails\en\order_conf.html file:

Put this code:

 

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

Before this code:

 

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

Good luck!

 

My email template with this addon:

post-231092-0-41623400-1447764567_thumb.jpg

PaymentModule.php

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

  • 3 months later...

/modules/mailalerts/mailalerts.php 

 

mail alerts not wokring 

 

versiyon 1.6.1.3

 

 

edited

 

Please upload file, do not copy all the entire code file here!

If you look better you will see that this post about "Customer Order Mail", not about mailalerts module.

For your question please made new post with your problem.

Link to comment
Share on other sites

  • 2 weeks later...

Inside file PaymentModule.php find lines with number 352 and 354. You will see IMG tags inside php code, edit this lines to change image sizes or just try remove (width="160" height="213")

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

 

This method is not working for 1.6.1.4. I get a blank page in frontpage.

 

Could you please help?

 

Thanks a lot

 

Its work great on 1.6.1.4, you do some thing wrong. Turn on display error and you will see where you have error.

Link to comment
Share on other sites

Its work great on 1.6.1.4, you do some thing wrong. Turn on display error and you will see where you have error.

 

Hi, I get it to work more or less.

 

I have two payment methods: Default bank transfer and a paid one (pay on delivery with fee).

 

The second one is not showing pictures.

 

Any ideas?

 

Thanks a lot.

 

Regards

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
  • 4 months later...
  • 2 weeks later...

I made override file for easy setup and attach it to this message.

 

Upload this file in this dir:

 

\override\classes\PaymentModule.php

 

After delete this file: /cache/class_index.php

 

After you need edit your email template:

 

\mails\en\order_conf_product_list.tpl

 

Put this code:

 

 

	<td style="border:1px solid #D6D4D4;">
		<table class="table">
			<tr>
				<td width="10"> </td>
				<td>
					<font size="2" face="Open-sans, sans-serif" color="#555454">
						{$product['image']}
					</font>
				</td>
				<td width="10"> </td>
			</tr>
		</table>
	</td>

Before this code:

 

 

	<td style="border:1px solid #D6D4D4;">
		<table class="table">
			<tr>
				<td width="10"> </td>
				<td>
					<font size="2" face="Open-sans, sans-serif" color="#555454">
						{$product['reference']}
					</font>
				</td>
				<td width="10"> </td>
			</tr>
		</table>
	</td>

Also edit \mails\en\order_conf.html file:

Put this code:

 

 

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

Before this code:

 

 

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

 

 

Thank you it WORKS in 1.6.1.0 BUT... There is one thing which i need to solve, it don´t work properly with product combinations. It show just "default" image, but not image which is assigned to combination color. See my screenshot for example. Can you please help? THANK YOU

post-804755-0-38368800-1474277905_thumb.jpg

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

  • 2 months later...
  • 2 months later...

Inside PaymentModule.php you can find this code inside foreach():

 

  $product_var_tpl = array(
    'reference' => $product['reference'],
    '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()
); You need put your code before this code, and after pass new variable in template.
You need put your code before this code, and after pass new variable in template.

 

like that:

$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()
);
and then inside template write this: 

{$product['image']}
and you get full image tag with image url.

In code change "medium_default" on your image size type.

 

Also if product don't have image you will see default product image in mail template: en-default-medium_default.jpg, change "en" if you have different language.

 

 

Hi All,

 

I follow the above steps on 1.6.1.10 but not sure why the image still not showing up. Attached is a screenshot

OrderConfirmationError.JPG

 

I have even tested on PaymentModule.php with the below code to ensure the image url is correct, which works fine.

echo "<pre>"; print_r($image); echo "</pre>"; exit();

 

Appreciate some help/advise.

 

Thanks in advance !!

 

Cheers,

Jac

Link to comment
Share on other sites

  • 1 month later...

Hi,

I got it worked so it shows product image in order email, but I need to show product combination image. For example if I choose to buy blue car in my order email it shows blue car, not the default product image (for example red car). Any ideas how to do it?

Link to comment
Share on other sites

  • 2 weeks later...

I'm on 1.6.0.9

 

I tried

$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()
);

+ modification on order_conf.html

{$product['image']}
it does not work :(
 
 
idea? (I'm on 1.6.0.9)
Link to comment
Share on other sites

 

I'm on 1.6.0.9

 

I tried

$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()
);

+ modification on order_conf.html

{$product['image']}
it does not work :(
 
 
idea? (I'm on 1.6.0.9)

 

 

bump :)

Link to comment
Share on other sites

  • 4 weeks later...

Hi , 
Presta 1.6.1.13
 
Need remove 'product reference' from email order confirm to client
 
on PaymentModule.php

I have deleted  this code

 

'reference' => $product['reference'],

 

 in line 463  :

 

now my code is : 

 

   $product_var_tpl = array(
                            '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()
                        );
 
 
 

Upload PaymentModule.php  in this dir:

 

\override\classes\

 

After delete this file: /cache/class_index.php

 

But i have the same email ...

 

I have Also edit \mails\it\order_conf.html.....

 

Where i have mistake ?

 

Thanks 

post-1399000-0-11880500-1496241955_thumb.jpg

Link to comment
Share on other sites

  • 2 months later...

Hi,

I got it worked so it shows product image in order email, but I need to show product combination image. For example if I choose to buy blue car in my order email it shows blue car, not the default product image (for example red car). Any ideas how to do it?

I have the same request. Please is here anybody who can edit the code for showing combination IMAGE? Thanks, it would be awesome! Btw everything working in 1.6.1.0. !!! Thanks. 

Link to comment
Share on other sites

  • 2 weeks later...
$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="http://mysite.com/img/p/'.$folder.$cover['id_image'].'-medium_default.jpg" alt="" width="125" height="125" />';
} else {
	$image = '<img src="http://mysite.com/img/p/ru-default-medium_default.jpg" alt="" width="125" height="125" class="imgm img-thumbnail" />';
} 

this great work for Mail alerts module in PrestaShop 1.6.1.12.

I put this code in /modules/mailalerts/mailalerts.php before $items_table near 316 line and replace content in second column

		  <strong><a href="'.$url.'">'.$product['product_name'].'</a>'
							.(isset($product['attributes_small']) ? ' '.$product['attributes_small'] : '')
							.(!empty($customization_text) ? '<br />'.$customization_text : '')
					    	.'</strong>

to:

					  <table border="0">
					    <tr>
					    <td width="158">' . $image .  '</td>
					     <td>
						  <strong><a href="'.$url.'">'.$product['product_name'].'</a>'
							.(isset($product['attributes_small']) ? ' '.$product['attributes_small'] : '')
							.(!empty($customization_text) ? '<br />'.$customization_text : '')
					    	.'</strong>
					      </td>
					     </tr>
					   </table>

Now I receive order messages with images of the products. This is convenient for me. Probably, it will be correct to replace mysite.com with a variable of the base URL or a constant. Sorry for my poor English.   

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 4 months later...
On 11/10/2015 at 11:32 AM, Kerm said:

Its work on 1.6.1.x

 

Hello Kerm,

I followed your instructions but unluckily that it is not working on 1.6.1.5. There is no images showing on email order as you can see in the screenshot attached. Could you please let me know why?

Thank you!

 

 

test.png

Link to comment
Share on other sites

  • 3 months later...
On 2/9/2017 at 8:35 AM, imjacwu said:

  On 7/28/2015 at 6:11 PM, wiseprt said:

1

 

 

Hi,

I have implemented that but it still not displaying image.

and in email image tag  showing unknow src 

 

Thanks

 

Link to comment
Share on other sites

  • 1 year later...
					$product_var_tpl_list = array();
					foreach ($order->product_list as $product)
					{
						$price = Product::getPriceStatic((int)$product['id_product'], false, ($product['id_product_attribute'] ? (int)$product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int)$order->id_customer, (int)$order->id_cart, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
						$price_wt = Product::getPriceStatic((int)$product['id_product'], true, ($product['id_product_attribute'] ? (int)$product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int)$order->id_customer, (int)$order->id_cart, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});

						$product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt;

						$product_var_tpl = array(
							'reference'					$product_var_tpl_list = array();
					foreach ($order->product_list as $product)
					{
						$price = Product::getPriceStatic((int)$product['id_product'], false, ($product['id_product_attribute'] ? (int)$product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int)$order->id_customer, (int)$order->id_cart, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
						$price_wt = Product::getPriceStatic((int)$product['id_product'], true, ($product['id_product_attribute'] ? (int)$product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int)$order->id_customer, (int)$order->id_cart, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});

						$product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt;

						$product_var_tpl = array(
							'reference' => $product['reference'],
							'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()
						); => $product['reference'],
							'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()
						);

Заменив участок кода, что выше, участком кода, что ниже.

					$product_var_tpl_list = array();
                    foreach ($order->product_list as $product) {
                        $price = Product::getPriceStatic((int)$product['id_product'], false, ($product['id_product_attribute'] ? (int)$product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int)$order->id_customer, (int)$order->id_cart, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
                        $price_wt = Product::getPriceStatic((int)$product['id_product'], true, ($product['id_product_attribute'] ? (int)$product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int)$order->id_customer, (int)$order->id_cart, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});

                        $product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt;

                        $cover = Image::getCover((int)$product['id_product']); // array image
                        $id_shop = $this->context->shop;
                        $force_ssl = (Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE'));
                        $language_prefix = $this->context->language->iso_code;

                        if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && $id_shop !== null) {
                            $shop = new Shop($id_shop);
                        } else {
                            $shop = Context::getContext()->shop;
                        }

                        if ($relative_protocol) {
                            $base = '//'.($ssl && $this->ssl_enable ? $shop->domain_ssl : $shop->domain);
                        } else {
                            $base = (($ssl && $this->ssl_enable) ? 'https://'.$shop->domain_ssl : 'http://'.$shop->domain);
                        }

                        $base_url = $base.$shop->getBaseURI();


                        $domain = Configuration::get('PS_SHOP_DOMAIN');
                        if (sizeof($cover['id_image']) > 0) {
                            $folder = Image::getImgFolderStatic($cover['id_image']);  // folders inside /img/p/
                            $image = '<img src="'.$base_url.'img/p/'.$folder.$cover['id_image'].'-cart_default.jpg" alt="" width="160" height="213" class="imgm img-thumbnail" />';
                        } else {
                            $image = '<img src="'.$base_url.'img/p/'.$language_prefix.'-default-cart_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()
                        );

При этом выполнив инструкцию, цитируемого поста. Спасибо!

PaymentModule.php

Link to comment
Share on other sites

On 17.11.2015 at 14:47, Kerm said:

Я сделал файл переопределения для легкой настройки и приложил его к этому сообщению.

 

Загрузить этот файл в этот каталог:

 

\ переопределение \ Классы \ PaymentModule.php

 

После удаления этого файла: /cache/class_index.php

 

После того, как вам нужно отредактировать ваш шаблон электронной почты:

 

\ почта \ EN \ order_conf_product_list.tpl

 

Поместите этот код:

 


	 
		 
			
				  
				
					   
					
				
				  
			
		
	

Перед этим кодом:

 


	 
		 
			
				  
				
					   
					
				
				  
			
		
	

Также отредактируйте файл \ mails \ en \ order_conf.html:

Поместите этот код:

 


      

Перед этим кодом:

 


      

Удачи!

 

Мой шаблон электронной почты с этим дополнением:

после 231092-0-41623400-1447764567_thumb.jpg

PaymentModule.php

Спасибо за помощь, у меня вышло заменив определнный участко кода

Link to comment
Share on other sites

  • 1 year later...

Hello,

I'm reanimating this dead cold topic because I was trying to implement the same thing in my shop. I am using PrestaShop 1.7.5.1 but the proposed method was for 1.6 and it doesn't work on my version.

Does anyone know how to make it work?

Thanks!

Link to comment
Share on other sites

  • 1 month later...
En 25/6/2020 a las 3:52 AM, Ale_BB dijo:

Hola,

Estoy reanimando este tema frío porque estaba tratando de implementar lo mismo en mi tienda. Estoy usando PrestaShop 1.7.5.1 pero el método propuesto fue para 1.6 y no funciona en mi versión.

¿Alguien sabe cómo hacer que funcione?

¡Gracias!

Hola Ale pudiste encontrar alguna solucion, me gustaria hacer lo mismo 

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