Jump to content

Show order note in invoice PDF


dmo@hispeed.ch

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}
      {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

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">&nbsp;</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

  • Thanks 1
Link to comment
Share on other sites

  • 9 months later...

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

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