germinc Posted July 2, 2019 Share Posted July 2, 2019 Ok so I hunted everywhere and I could not find it on any forums, so I paid someone on Upwork to do it for me, use it if it helps you. All this does is take the customer message from the order process, and add it to the Invoice so my packers will be able to take note of any special requests. I am using this code on Prestashop 1.7.5.1 In /classes/order/OrderInvoice.php file and add the following code in line 179 if( end($products) === $row ) { $row['first_order_message'] = nl2br($order->getFirstMessage()); } In pdf/invoice.product-tab.tpl file add this to the end <!-- Customer Order Message --> <br/> {if isset($order_detail.first_order_message) && $order_detail.first_order_message} <table class="product" width="100%" cellpadding="4" cellspacing="0" style="margin-top: 10px"> <thead> <tr class="product" style="width: 100%"> <th class="product header small" width="100%">{l s='Customer Message' d='Shop.Pdf' pdf='true'}</th> </tr> </thead> <tbody> <tr class="product left {$bgcolor_class}" style="width: 100%"> {foreach $order_details as $order_detail} <td class="product left"> {$order_detail.first_order_message} </td> {/foreach} </tr> </tbody> </table> {/if} <!-- Customer Order Message --> If you want to buy me a coffee, here's the link: https://www.paypal.me/jeremyko88 Cheers! Link to comment Share on other sites More sharing options...
Behc98 Posted January 1, 2020 Share Posted January 1, 2020 (edited) \classes\order\OrderInvoice.php public function getProducts($products = false, $selected_products = false, $selected_qty = false) { if (!$products) { $products = $this->getProductsDetail(); } $order = new Order($this->id_order); $customized_datas = Product::getAllCustomizedDatas($order->id_cart); $result_array = array(); foreach ($products as $row) { // hack start if( end($products) === $row ) { $row['first_order_message'] = nl2br($order->getFirstMessage()); $CustomerThread_messagelar = CustomerMessage::getMessagesByOrderId($order->id, $private = false); // last Customer Message private = false $row['CustomerThread_message'] = $CustomerThread_messagelar[0][message]; // last Customer Message // ddd($CustomerThread_message); } in invoice.tpl {$order_detail.CustomerThread_message} Edited January 1, 2020 by behcet (see edit history) Link to comment Share on other sites More sharing options...
Toranzo Posted January 2, 2020 Share Posted January 2, 2020 Hello, I have a problem with the conditional that controls if there are messages, without that conditional works for me perfect: <!-- {if isset($order_details.first_order_message) && $order_detail.first_order_message} --> <td width="40%"><span class="bold">Mensaje Pedido</span><br/><br/> {foreach $order_details as $order_detail} <span id="mensajefacturas" >{$order_detail.first_order_message}</span> {/foreach} </td> <!-- {/if}--> Thanks for the code Link to comment Share on other sites More sharing options...
kyripapa Posted February 20, 2020 Share Posted February 20, 2020 Hello dev, I have an issue. If the order is one product then the customer message appears in the invoice. If the products are more than one then I have a blank customer message. Any ideas why that is happening? Kind Regards, Link to comment Share on other sites More sharing options...
Trade1 Posted May 9, 2020 Share Posted May 9, 2020 On 7/2/2019 at 4:33 AM, germinc said: Ok so I hunted everywhere and I could not find it on any forums, so I paid someone on Upwork to do it for me, use it if it helps you. All this does is take the customer message from the order process, and add it to the Invoice so my packers will be able to take note of any special requests. I am using this code on Prestashop 1.7.5.1 In /classes/order/OrderInvoice.php file and add the following code in line 179 if( end($products) === $row ) { $row['first_order_message'] = nl2br($order->getFirstMessage()); } In pdf/invoice.product-tab.tpl file add this to the end <!-- Customer Order Message --> <br/> {if isset($order_detail.first_order_message) && $order_detail.first_order_message} <table class="product" width="100%" cellpadding="4" cellspacing="0" style="margin-top: 10px"> <thead> <tr class="product" style="width: 100%"> <th class="product header small" width="100%">{l s='Customer Message' d='Shop.Pdf' pdf='true'}</th> </tr> </thead> <tbody> <tr class="product left {$bgcolor_class}" style="width: 100%"> {foreach $order_details as $order_detail} <td class="product left"> {$order_detail.first_order_message} </td> {/foreach} </tr> </tbody> </table> {/if} <!-- Customer Order Message --> If you want to buy me a coffee, here's the link: https://www.paypal.me/jeremyko88 Cheers! Thanks for sharing this information, I have followed your guide but the message does not appear in the pdf in PS_1.7.5.1 Can you share the two files? Thanks in advance Link to comment Share on other sites More sharing options...
nsm Posted November 25, 2020 Share Posted November 25, 2020 works on 1.7.5.2 coffee for you Link to comment Share on other sites More sharing options...
maniot Posted May 11, 2021 Share Posted May 11, 2021 I can't get it working on 1.7.7.1, i think it has to do with the changes in 1.7.7. Does anyone know how to get this in version 1.7.7.1? Link to comment Share on other sites More sharing options...
w3bsolutions Posted June 5, 2021 Share Posted June 5, 2021 (edited) On 1/1/2020 at 6:35 PM, behcet said: foreach ($products as $row) { // hack start if( end($products) === $row ) { $row['first_order_message'] = nl2br($order->getFirstMessage()); $CustomerThread_messagelar = CustomerMessage::getMessagesByOrderId($order->id, $private = false); // last Customer Message private = false $row['CustomerThread_message'] = $CustomerThread_messagelar[0][message]; // last Customer Message } You are retrieving the same message inside the products loop... the message should only be retrieved once and outside the loop. Edited June 5, 2021 by w3bsolutions (see edit history) Link to comment Share on other sites More sharing options...
Behc98 Posted June 5, 2021 Share Posted June 5, 2021 (edited) Do not put it in the product line! I put it in the top right, below the date line. in invoice.tpl <td style="font-size: 9pt; width: 35%;"> <br /><span>{$carrier->name}</span> <br /><span>{foreach from=$order_invoice->getOrderPaymentCollection() item=payment} {$payment->payment_method} : {displayPrice currency=$payment->id_currency price=$payment->amount} {/foreach} </span> <span> {foreach $order_details as $order_detail}{/foreach} <br />Not:{$order_detail.first_order_message} <br /> {if $order_detail.CustomerThread_message != $order_detail.first_order_message} Not:{$order_detail.CustomerThread_message} {/if} </span> </td> Edited June 5, 2021 by Behc98 (see edit history) Link to comment Share on other sites More sharing options...
Behc98 Posted June 5, 2021 Share Posted June 5, 2021 this sample, 4 product, 1 message. prestashop 1.6 Link to comment Share on other sites More sharing options...
w3bsolutions Posted June 5, 2021 Share Posted June 5, 2021 (edited) Because you are retrieve the same message over and over. Don't you see you are fetching the message inside a loop? This is your code: foreach ($products as $row) { // fetching message } // you should fetch message HERE Never mind... I see you have an if in there to check that is is the last row.. still it would be a lot cleaner to have it outside. Edited June 5, 2021 by w3bsolutions (see edit history) Link to comment Share on other sites More sharing options...
Behc98 Posted June 5, 2021 Share Posted June 5, 2021 in \classes\order\OrderInvoice.php $row['CustomerThread_message'] = $CustomerThread_messagelar[0][message]; and I am using {$order_detail.CustomerThread_message} in my invoice.tpl file Link to comment Share on other sites More sharing options...
MightyMouseofGod Posted August 18, 2022 Share Posted August 18, 2022 I've been trying to follow this but my Invoice.tpl looks different. It looks like they create the invoice in bits and then put it together at the end now. I've updated to 1.7.8.7 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