Jump to content

How to add product short description in order confirmation mail


Recommended Posts

Hello,

 

i'm looking in to that for quiet a while but i can't find a solution, maybe you guys can help me.

I'm trying to put the product short description in to the order confirmation mail.

In "mailalerts.php" i added "$product['description_short']" in Line 314, but that dosen't work.
 

$items_table .='
<tr style="background-color:'.($key % 2 ? '#DDE2E6' : '#EBECEE').';">
<td style="padding:0.6em 0.4em;">'.$product['product_reference'].'</td>
<td style="padding:0.6em 0.4em;"><strong>'.$product['product_name'].$product['description_short'].(isset($product['attributes_small']) ? ' '.$product['attributes_small'] : '').(!empty($customization_text) ? '<br />'.$customization_text : '').'</strong></td>


I think that the variable "$product['description_short']" is not defined in the System.

 

Can somebody tell me where i can define the variable oder where i can get the product short description data from the SQL Database.

 

Prestashop Version 1.5.3.1

 

Thanks a lot.

 

Cu Stefan

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

You have to grab it in

 

public function getProductsDetail()
{
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT *
FROM `'._DB_PREFIX_.'order_detail` od
LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product = od.product_id)
LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (ps.id_product = p.id_product AND ps.id_shop = od.id_shop)
WHERE od.`id_order` = '.(int)($this->id));
}
 
 
Order class :)
Link to comment
Share on other sites

Thanks Nemo,

 

I added the following line to /classes/order/Order.php

LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.id_product = p.id_product AND pl.`id_lang` = 3)

I hardcoded the lang code id, i guess thats fine for now.

 

I tested my SQL query and it works, and the Product short description shows up in the mail that the store owner gets on an new order, but i should also appear in the customers oder confirmation. So that means I'm editing the wrong File, maybe mailalerts.php is the wrong source ?

 

Thanks for your help.

 

Cu Stefan

Link to comment
Share on other sites

  • 1 month later...

Hello, I'm getting some problems trying to follow these instructions. Can you help me, please?

 

I'm not an expert with code so I need a step by step explanation.

 

At least, am I doing ok the first step?

 

Step 1.-

 

Add

 

LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.id_product = p.id_product AND pl.`id_lang` = 3)

 

to /classes/order/Order.php

 

public function getProductsDetail()
{
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT *
FROM `'._DB_PREFIX_.'order_detail` od
LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product = od.product_id)
LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (ps.id_product = p.id_product AND ps.id_shop = od.id_shop)
WHERE od.`id_order` = '.(int)($this->id));
}
 
Thanks!
Link to comment
Share on other sites

Ok, so step 1 done.

 

If I want to show the description in the customers order confirmation the next step would be modify the paymentModule class, validateOrder method as you said before? If that's correct, please tell me what code I have to add/replace and where.

 

Thanks for your time!

Link to comment
Share on other sites

Try from line 365 onwards

foreach ($order->product_list as $key => $product)
					{

Inside this foreach, I guess you can use $product['description_short'] at this point. The table that follows is the  one printed in the email

  • Like 1
Link to comment
Share on other sites

Try from line 365 onwards

foreach ($order->product_list as $key => $product)
					{

Inside this foreach, I guess you can use $product['description_short'] at this point. The table that follows is the  one printed in the email

Thanks Nemo1, it works perfect!

 

But I tried the same with $product['description'] and I don't get any result. The variable for the normal description of the product isn't $product['description']?

Link to comment
Share on other sites

hm try with description_short

Hi Nemo1, sorry maybe I didn't explain myself before. $product['description_short'] is working fine for short product description. But I also want to include the regular product description, which is called description in the database. As I told you before I tried with $product['description'] but it doesn't work as $product['description_short'] does.

 

There is no need to make proves with description_short because it works with your previous solution.

Link to comment
Share on other sites

Hm... I see. Try var_dump($product);

 

See if description is assigned as key, it should, it's weird, as you used * and joined the product_lang table

I did it and description is not assigned as key. How can I assign it?

Link to comment
Share on other sites

You must climb up the code and find the original array of products, then see which method is used to grab them, and modify if so pl.description is added :)

 

Yes, it's me again, don't hate me.

 

Google is not helping me to find the original array and his method.

 

In paymentModule.php there is:

foreach ($order->product_list as $key => $product)

So the original array is $order->product_list?

 

But before that, we have:

foreach ($package_list as $id_address => $packageByAddress)
				foreach ($packageByAddress as $id_package => $package)
				{
					$order = new Order();
					$order->product_list = $package['product_list'];

I'm totally lost. Which is the original array and how I can know the method used to get it?

Link to comment
Share on other sites

I hate you!

 

:D

 

Yes, it's quite complex, I struggled with it myself.

Try editing cart::getProducts() and add it there

 

Yesss!! Great work Nemo1, now it's working perfect.

 

Thanks for your effort and specially for your patience!  :D

Link to comment
Share on other sites

  • 4 months later...

I hate you!

 

:D

 

Yes, it's quite complex, I struggled with it myself.

Try editing cart::getProducts() and add it there

 
Hello,
 
After making those changes i can add the description_short in the order confirmation mail sent to the customer. But i need the same to the admin email as well.
 
Not been able to trace cart::getProducts(). Which file is it.
 
Please help me where i am missing to add the variable.

 

Thanks,

Link to comment
Share on other sites

×
×
  • Create New...