Jump to content

Show order note in invoice PDF


Recommended Posts

 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}

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...


Like I said it's a sloppy way to do it but that's how I roll 🤣

Link to comment
Share on other sites

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} 
			<td colspan="12" height="10">&nbsp;</td>

			<td colspan="12" >
			<table id="note-tab" style="width: 100%">
							<th class=" header small">{l s='Note' d='Shop.Pdf' pdf='true'}</th>
						{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>

Have a nice day.


  • Thanks 1
Link to comment
Share on other sites

  • 9 months later...


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

  • 6 months later...

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


        <td colspan="1">&nbsp;</td>



hope this helps you too :)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...