KolfKord Posted March 20, 2013 Share Posted March 20, 2013 Hello guys, I need a big help. How do I put a short description of a product on the invoice? I did several searches on the web and I saw the form M4 PDF Extensions but it costs € 99 and I can not afford ... Is there a way to do this via code? ... Help Please ... Link to comment Share on other sites More sharing options...
Dustin Posted March 21, 2013 Share Posted March 21, 2013 yes sure if you want i can help you with that Link to comment Share on other sites More sharing options...
KolfKord Posted March 21, 2013 Author Share Posted March 21, 2013 yes sure if you want i can help you with that I would be really debtor ... I have already acted on file PDF.php for other things, but do not know how to put a short description ... Link to comment Share on other sites More sharing options...
KolfKord Posted March 23, 2013 Author Share Posted March 23, 2013 Dustin... Link to comment Share on other sites More sharing options...
Zhivko Posted March 23, 2013 Share Posted March 23, 2013 (edited) You may define a new function in OrderInvoice class to retrieve product short description. See function getProducts - you have order detail information as $row => you may call your function using $row['id_product'] (and product_attribute_id) and retrieve it's short description using SQL. Then it might be assigned to $row['product_short_desc']. You will use this information in invoice.tpl somewhere in {foreach $order_details as $order_detail}, it will be {$order_detail.product_short_desc} Honestly, I didn't test it but it should work like that. PDF variables are collected in HTMLTemplateInvoice.php, 'order_details' => $this->order_invoice->getProducts() Edited March 23, 2013 by Zhivko (see edit history) Link to comment Share on other sites More sharing options...
KolfKord Posted March 26, 2013 Author Share Posted March 26, 2013 (edited) You may define a new function in OrderInvoice class to retrieve product short description. See function getProducts - you have order detail information as $row => you may call your function using $row['id_product'] (and product_attribute_id) and retrieve it's short description using SQL. Then it might be assigned to $row['product_short_desc']. You will use this information in invoice.tpl somewhere in {foreach $order_details as $order_detail}, it will be {$order_detail.product_short_desc} Honestly, I didn't test it but it should work like that. PDF variables are collected in HTMLTemplateInvoice.php, 'order_details' => $this->order_invoice->getProducts() I did not understand which file I need to change! I have prestashop 1.4.8.2 Edited March 26, 2013 by KolfKord (see edit history) Link to comment Share on other sites More sharing options...
Zhivko Posted March 26, 2013 Share Posted March 26, 2013 1. OrderInvoice class is located in /classes/order/OrderInvoice.php Add some code to extract product short description to getProducts result. Example: put this code in function getProducts after $row['id_address_delivery'] = $order->id_address_delivery; $sql = SELECT `description_short` FROM `'._DB_PREFIX_.'product` WHERE `id_product` = '.(int)$row['id_product']; $row['product_desc_short'] = Db::getInstance()->getValue($sql); 2. Invoice template is located in /pdf/invoice.tpl Add some code to display product short description. Example: modify the product name display: <td style="text-align: left; width: 45%">{$order_detail.product_name}</td> Add product short description in the same cell of the table, under the name <td style="text-align: left; width: 45%">{$order_detail.product_name}</br>{$order_detail.product_desc_short}</td> 1 Link to comment Share on other sites More sharing options...
leeego Posted July 25, 2013 Share Posted July 25, 2013 Does anyone know a way to do this in PrestaShop 1.5? I thought it might be possible to use attributes_small from Cart.php for that, but couldn't get it work so far. Link to comment Share on other sites More sharing options...
veravalonline Posted September 7, 2013 Share Posted September 7, 2013 1. OrderInvoice class is located in /classes/order/OrderInvoice.php Add some code to extract product short description to getProducts result. Example: put this code in function getProducts after $row['id_address_delivery'] = $order->id_address_delivery; $sql = SELECT `description_short` FROM `'._DB_PREFIX_.'product` WHERE `id_product` = '.(int)$row['id_product']; $row['product_desc_short'] = Db::getInstance()->getValue($sql);2. Invoice template is located in /pdf/invoice.tplAdd some code to display product short description. Example: modify the product name display: <td style="text-align: left; width: 45%">{$order_detail.product_name}</td> Add product short description in the same cell of the table, under the name <td style="text-align: left; width: 45%">{$order_detail.product_name}</br>{$order_detail.product_desc_short}</td> it doesnt work at all, it crashes the whole site Link to comment Share on other sites More sharing options...
torchs Posted October 16, 2013 Share Posted October 16, 2013 there is another solution for to put a short description of a product on the invoice pdf? i have prestashop 1.5.6 thank you very much! Link to comment Share on other sites More sharing options...
tuk66 Posted October 17, 2013 Share Posted October 17, 2013 Similar post is here - http://www.prestashop.com/forums/topic/269214-add-short-description-into-invoice-like-in-pdf-file-invoicetpl/ Link to comment Share on other sites More sharing options...
avdleun Posted October 28, 2013 Share Posted October 28, 2013 (edited) I made some changes that worked for me in pretaShop 1.5.4.1 : Keep in mind that I am not a presta shop expert ! pdf/invoice.tpl: change : <td style="text-align: left; width: 45%">{$order_detail.product_name}</td> to <td style="text-align: left; width: 45%">{$order_detail.product_name} - {$order_detail.description_short}</td> classes/order/OrderInvoice.php: change: 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.' AND od.`id_order_invoice` = '.(int)$this->id); } to: 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_lang` pl ON pl.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.' AND od.`id_order_invoice` = '.(int)$this->id); } That should do the trick ! MODIFIED on nov 11 2013: Original there were also some changes in file: classes/order/OrderDetail.php This was wrong and not needed ! (if it was changed, the application crashed on new orders) Edited November 11, 2013 by avdleun (see edit history) 1 Link to comment Share on other sites More sharing options...
torchs Posted October 29, 2013 Share Posted October 29, 2013 great avdleun !!!!!!! it work very well on prestashop 1.5.6 thank you very much from italy! :) Link to comment Share on other sites More sharing options...
rictools Posted July 8, 2016 Share Posted July 8, 2016 Also works in 1.6.1.4 ! Thanks! Link to comment Share on other sites More sharing options...
clmoulin Posted September 14, 2016 Share Posted September 14, 2016 I tried your suggestion on Prestashop 1.6.1.6 -I changed the code of the function getProductsDetail() exactly as you did -I added this code to invoice.product-tab.tpl <td class="product center"> {$order_detail.description_short} </td> - I let the invoice.tpl as it is: <td colspan="12"> {$product_tab} </td> But I get the "demo" short description of the template product (which is about a T-Shirt) and not my own short description. Any idea? thanks a lot in advance! Link to comment Share on other sites More sharing options...
rictools Posted September 15, 2016 Share Posted September 15, 2016 I tried your suggestion on Prestashop 1.6.1.6 -I changed the code of the function getProductsDetail() exactly as you did Maybe a typo in this part? Please note that the original post is 3 years old. Link to comment Share on other sites More sharing options...
Skort46 Posted November 17, 2016 Share Posted November 17, 2016 Hello, I dont speak English very well sorry... Any Idea for 1.6.1.9 ??? I need your help... Thanks ! Link to comment Share on other sites More sharing options...
rictools Posted November 17, 2016 Share Posted November 17, 2016 Any Idea for 1.6.1.9 ??? Post #12 works for me in 1.6.1.4, so it should work in 1.6.1.9 too, try and clear all caches. Link to comment Share on other sites More sharing options...
Skort46 Posted December 1, 2016 Share Posted December 1, 2016 Post #12 works for me in 1.6.1.4, so it should work in 1.6.1.9 too, try and clear all caches. I'm noob... I can not make it work... Link to comment Share on other sites More sharing options...
Skort46 Posted December 1, 2016 Share Posted December 1, 2016 <!-- Product --> <tr> <td colspan="12"> {$product_tab} </td> </tr> In 1.6.1.9, the code is really different .... 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