Jump to content

Add products descriptions in the order confirmation email


Recommended Posts

Hello

I try to add the description of each product in the order confirmation email sent to the customer.

In /mails/en/order_conf_product_list.tpl the product name is called as follows:

{$ Product [ 'name']}

But this does not work for {$ product ['description']}, the variable is not defined.


How to define it? (In the paymentModule.php class I guess but how?)


Thank you !

Link to comment
Share on other sites

  • 1 month later...

You need to add this varialbe within PaymentModule.php.

If you have opened the file, you search for $data = array.

There you'll find all existing variables. Add yours and watch out for the commads at the end of the array fields.

Then change your mail template accordingly and your are done.

 

Valid for PS 1.6. since you haven't given and hint on your version in use.

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

It's 1.6 indeed, sorry. 

 

In fact in pyamentModule.php there is this :

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')}); 
etc.
}

How to get each product description on the same way ? Is there any function to retrieve description ?

Link to comment
Share on other sites

Okay, you are on the right path. And ineed I forgot that the produc texts are based on predefined list. If you search for

$product_list_txt

or

$product_list_html

you'll find some code like this.

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

This is where templates are fetched and filled with the product detail data. This is where you have to stick in deeper. The function called is named

getEmailTemplateContent

I think you have to open the template files which are shown in the code above.

Link to comment
Share on other sites

First of all - I haven't solved this exact question before. So I am trying hard to help you out.... BUT

But how to define $product['description'] ?

I can only read the same and the same question ... About 4 times now. If you are willing to learn, you are welcome.

If you only want to get perfectly running code, I might be the wrong to help out.

 

Description is not yet filled. The variables handed over to the tpl. files are defined in $product_var_tpl_list

This is the way to look further in PaymentModule.php,

As you can see, there isn't always a straight forward approach. It needs time to dig in.

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

And one more hint:

The product description is the long text. Which means: it can contain all sorts of HTML text, image links etc cetera. Which means in terms of putting this into the email: It would most likely breakup all the formatting. Also the length of this field might lead to some issues. It can contain up to 6000 characters. So be prepared it needs quite much tag cleaning before you can use the full description.

Link to comment
Share on other sites

Description is not yet filled. The variables handed over to the tpl. files are defined in $product_var_tpl_list

This is the way to look further in PaymentModule.php,

As you can see, there isn't always a straight forward approach. It needs time to dig in.

I dug, without finding it. That's the reason why I posted here.

As said in my first message I already knew where to dig. In fact I have already found how to display the product image on the mail, using

$cover = Image::getCover((int)$product['id_product']);
Image::getImgFolderStatic($cover['id_image']);
etc.

But sorry, I may be dumb (I am) but I can't find how to do the same for the (short) description.

 

 

Link to comment
Share on other sites

I confirm I'm dumb : I had it but I was calling the wrong variable: description instead of description_short. And as description is empty for all my products I tought I was using the wrong method.
 

$product_var_tpl = array(
  'description' => $product['description_short'],


 

Link to comment
Share on other sites

  • 1 year later...
On 14. 9. 2017 at 11:27 AM, Anatole said:

I confirm I'm dumb : I had it but I was calling the wrong variable: description instead of description_short. And as description is empty for all my products I tought I was using the wrong method.
 


$product_var_tpl = array(
  'description' => $product['description_short'],


 

 

Hello @Anatole

1st step
In /mails/en/order_conf_product_list.tpl I change
{$product['name']} to {$product['description']} successfuly

 

2nd step
In classes/PaymentModule.php I add 'description' => $product['description_short'],
to "$product_var_tpl = array" list successfuly

and when I create new order it do not receive"Order confirmation" e-mail, I receive only "preparation" e-mail


Advanced settings > E-mail show, that order_confirmation was sent correctly.
 

Do not you know why?

 

Link to comment
Share on other sites

  • 2 years 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...