Anatole Posted August 4, 2017 Share Posted August 4, 2017 HelloI 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 More sharing options...
Anatole Posted September 11, 2017 Author Share Posted September 11, 2017 Anyone please ? Link to comment Share on other sites More sharing options...
Scully Posted September 12, 2017 Share Posted September 12, 2017 (edited) 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 September 12, 2017 by Scully (see edit history) Link to comment Share on other sites More sharing options...
Anatole Posted September 13, 2017 Author Share Posted September 13, 2017 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 More sharing options...
Scully Posted September 13, 2017 Share Posted September 13, 2017 You are in the completely wrong section. You have to search for this piece of code: $data = array It is followed by a long list of variable names. Link to comment Share on other sites More sharing options...
Anatole Posted September 13, 2017 Author Share Posted September 13, 2017 Yes, and in this long list of variables names there are '{products}' => $product_list_html, '{products_txt}' => $product_list_txt, But it doesn't tell me how to get each product description ? Link to comment Share on other sites More sharing options...
Scully Posted September 13, 2017 Share Posted September 13, 2017 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 More sharing options...
Anatole Posted September 13, 2017 Author Share Posted September 13, 2017 Yes indeed it's in order_conf_product_list.tpl file that I have to put {$product['description']} But how to define $product['description'] ? Link to comment Share on other sites More sharing options...
Scully Posted September 13, 2017 Share Posted September 13, 2017 (edited) 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 September 13, 2017 by Scully (see edit history) Link to comment Share on other sites More sharing options...
Scully Posted September 13, 2017 Share Posted September 13, 2017 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 More sharing options...
Anatole Posted September 14, 2017 Author Share Posted September 14, 2017 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 More sharing options...
Anatole Posted September 14, 2017 Author Share Posted September 14, 2017 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 More sharing options...
viktornadzam Posted October 20, 2018 Share Posted October 20, 2018 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 More sharing options...
ukbaz Posted March 8, 2021 Share Posted March 8, 2021 Is there a way to include the availability status message alongside the product name if a product is showing 'out of stock' in cart in the order confirmation email? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now