[email protected] Posted February 16, 2023 Share Posted February 16, 2023 (edited) When I enter a note on an order, I can't find the note in the ps_orders table and not in ps_order_invoice. But in table ps_customer_message I find my note. How can I display this note in the invoice PDF? Thanks and have a nice day! Edited February 16, 2023 by [email protected] (see edit history) Link to comment Share on other sites More sharing options...
lordignus Posted February 16, 2023 Share Posted February 16, 2023 It's not a pretty solution but it works... You could create a variable inside the invoice template (bad practice but I'm lazy) like: {$customer_messages = CustomerMessage::getMessagesByOrderId($order->id)} {$my_message = ''} {if $customer_messages} {foreach from=$customer_messages item=customer_message} {if $customer_message.id_employee} {$my_message = $customer_message.message} {break} {/if} {/foreach} {/if} This will get the newest note that you have entered onto the order, but will not display messages left by the customer. Then wherever you want the message to display, just call the variable... {$my_message} Like I said it's a sloppy way to do it but that's how I roll 🤣 Link to comment Share on other sites More sharing options...
[email protected] Posted February 20, 2023 Author Share Posted February 20, 2023 Dear @lordignus Thank you very much for your reply. I find it the best solution. Whether beautiful or not. It may make invoice generation a bit slower. But I don't see any other solution. It would be nice to pack the whole thing into a module and write it on the invoice via HOOK_DISPLAY_PDF. My code now looks like this (writen direct in invoice.tpl): {$msgs = CustomerMessage::getMessagesByOrderId($order_invoice->id_order)} {if $msgs|@count > 0} <tr> <td colspan="12" height="10"> </td> </tr> <tr> <td colspan="12" > <table id="note-tab" style="width: 100%"> <thead> <tr> <th class=" header small">{l s='Note' d='Shop.Pdf' pdf='true'}</th> </tr> </thead> <tbody> {foreach $msgs as $msg} {cycle values=["color_line_even", "color_line_odd"] assign=bgcolor_class} <tr class="{$bgcolor_class}"> <td class="center">{$msg.message|escape:'html':'UTF-8'|nl2br}</td> </tr> {/foreach} </tbody> </table> </td> </tr> {/if} Have a nice day. Daniel 1 Link to comment Share on other sites More sharing options...
Jontee Posted November 20, 2023 Share Posted November 20, 2023 Hi, I would really need this feature in one of my shops, which files did you guys edit more precisely? Anyone that could make an "official solution", I would gladly pay! A code snipped that works for 8.1.2 and upcoming version 9 etc. Best regards, Link to comment Share on other sites More sharing options...
patuga Posted June 6 Share Posted June 6 This also works for 8.1.2. I've just tested. thank you so much for sharing open file invoice.tpl inside public_html\pdf i've put the code on line 109, right under the code {$shipping_tab} </td> <td colspan="1"> </td> </tr> hope this helps you too Link to comment Share on other sites More sharing options...
patuga Posted July 10 Share Posted July 10 It's not a perfect solution, though. there are 22 PHP notice lines in the error_log every time there's a new order. PHP Notice: Undefined index: startcolumn in /home/XXXX/public_html/vendor/tecnickcom/tcpdf/tcpdf.php on line 19649 PHP Notice: Undefined index: startx in /home/XXXX/public_html/vendor/tecnickcom/tcpdf/tcpdf.php on line 19650 PHP Notice: Undefined index: startpage in /home/XXXX/public_html/vendor/tecnickcom/tcpdf/tcpdf.php on line 19653 PHP Notice: Undefined index: startpage in /home/XXXX/public_html/vendor/tecnickcom/tcpdf/tcpdf.php on line 19656 PHP Notice: Undefined index: in /home/XXXX/public_html/vendor/tecnickcom/tcpdf/tcpdf.php on line 19656 PHP Notice: Trying to access array offset on value of type null in /home/XXXX/public_html/vendor/tecnickcom/tcpdf/tcpdf.php on line 19656 PHP Notice: Undefined index: startpage in /home/XXXX/public_html/vendor/tecnickcom/tcpdf/tcpdf.php on line 19657 PHP Notice: Undefined index: in /home/XXXX/public_html/vendor/tecnickcom/tcpdf/tcpdf.php on line 19657 PHP Notice: Trying to access array offset on value of type null in /home/XXXX/public_html/vendor/tecnickcom/tcpdf/tcpdf.php on line 19657 PHP Notice: Trying to access array offset on value of type null in /home/XXXX/public_html/vendor/tecnickcom/tcpdf/tcpdf.php on line 2468 PHP Notice: Trying to access array offset on value of type null in /home/XXXX/public_html/vendor/tecnickcom/tcpdf/tcpdf.php on line 2468 PHP Notice: Undefined index: startcolumn in /home/XXXX/public_html/vendor/tecnickcom/tcpdf/tcpdf.php on line 19649 PHP Notice: Undefined index: startx in /home/XXXX/public_html/vendor/tecnickcom/tcpdf/tcpdf.php on line 19650 PHP Notice: Undefined index: startpage in /home/XXXX/public_html/vendor/tecnickcom/tcpdf/tcpdf.php on line 19653 PHP Notice: Undefined index: startpage in /home/XXXX/public_html/vendor/tecnickcom/tcpdf/tcpdf.php on line 19656 PHP Notice: Undefined index: in /home/XXXX/public_html/vendor/tecnickcom/tcpdf/tcpdf.php on line 19656 PHP Notice: Trying to access array offset on value of type null in /home/XXXX/public_html/vendor/tecnickcom/tcpdf/tcpdf.php on line 19656 PHP Notice: Undefined index: startpage in /home/XXXX/public_html/vendor/tecnickcom/tcpdf/tcpdf.php on line 19657 PHP Notice: Undefined index: in /home/XXXX/public_html/vendor/tecnickcom/tcpdf/tcpdf.php on line 19657 PHP Notice: Trying to access array offset on value of type null in /home/XXXX/public_html/vendor/tecnickcom/tcpdf/tcpdf.php on line 19657 PHP Notice: Trying to access array offset on value of type null in /home/XXXX/public_html/vendor/tecnickcom/tcpdf/tcpdf.php on line 2468 PHP Notice: Trying to access array offset on value of type null in /home/XXXX/public_html/vendor/tecnickcom/tcpdf/tcpdf.php on line 2468 And all messages get on the invoice instead of just the first one. 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