Jump to content

[Guide] Modifying Prestashop 1.5/1.6 Invoice Template.


Recommended Posts

Hi,

 

I have tried all I can to get these Order messages to work.

I have followed instructions on here, but cannot get messages to display on the invoice.

 

Now a customer has just placed an order with instructions.

On the invoice it states that they have, and shows the customers name and date/time of message.. but the message is blank :/

 

See pic attached

 

Any help with this is appreciated.

 

Ray

post-404663-0-73351200-1378562697_thumb.jpg

Share this post


Link to post
Share on other sites
  • Replies 279
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Greetings and Welcome to my first Guide.   Today we're going over how to modify the look of the Invoices generated by Prestashop 1.5 used in the DEFAULT theme. (If you use a custom theme, check your

Solved: How can customer messages be displayed in the pdf invoice? Jump to the bottom of this post for the solution - thanks to pointers from Bellini13!   I'm looking for the method to display mess

i would like to know as well how to remove the (empty) header.tpl margin   [sOLVED] Found the solution myself. Goto /classes/pdf/PDFgenerator.php   Around line 155 you will see   $this->s

Posted Images

Share this post


Link to post
Share on other sites

I would like to add the total weight and number of boxes to the invoice template. The latter is calculated by the UPS module and is of secondary importance. The total weight, however, is part of the PS database. What code should I use to insert it into the invoice template?

 

Thanks!

Share this post


Link to post
Share on other sites

Which means you need two components, the total weight itself and the weight unit, right?

 

total weight should be

{$cart->getTotalWeight()} 

and weight unit:

Configuration::get('PS_WEIGHT_UNIT') 

So you should use something like that:

{$cart->getTotalWeight().'  '.Configuration::get('PS_WEIGHT_UNIT')}
Edited by eleazar (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

 Thanks eleazar. I pasted your code in the following table. But when I try to generate a PDF, I get a server error in the browser. WHen I remove the code, the PDF is generated normally:

<table style="width: 100%">
<tr>
<td style="width: 15%; padding-right: 7px; text-align: right; vertical-align: top; font-size: 7pt;">
<!-- CUSTOMER INFORMATION -->
<b>{l s='Order Number:' pdf='true'}</b><br />
{$order->getUniqReference()}<br />
<br />
<b>{l s='Order Date:' pdf='true'}</b><br />
{dateFormat date=$order->date_add full=0}<br />
<br />
<b>{l s='Total Weight / #boxes:' pdf='true'}</b><br /><br />
{$cart->getTotalWeight().'  '.Configuration::get('PS_WEIGHT_UNIT')}<br />
<br />
<b>{l s='Payment Method:' pdf='true'}</b><br />
<table style="width: 100%;">
{foreach from=$order_invoice->getOrderPaymentCollection() item=payment}
<tr>
<td style="width: 50%">{$payment->payment_method}</td>
<td style="width: 50%">{displayPrice price=$payment->amount currency=$order->id_currency}</td>
</tr>
{foreachelse}
<tr>
<td>{l s='No payment' pdf='true'}</td>
</tr>
{/foreach}
</table>

What am I doing wrong?  :unsure:

Share this post


Link to post
Share on other sites

Hi,

 

maybe someone know how i can write in invoice customer fistname, lastname, postcode, city in diferent places?

I mean, now it is only delivery address as one part, but i need to make additional table in which all this info must be in diferent rows?

 

i tryed in invoice.tpl like this: {$delivery_address->city} (to get city only) but it not working...

Share this post


Link to post
Share on other sites

does anyone have an idea on how to add the customers VAT id on the invoice?

 

thanks

in HTMLtemplateinvoice.php getcontent() function add:

$vatnumber=$delivery_address-> vat_number;

in smarty assign add:

$this->smarty->assign(array(  :

'vatnumber' => $vatnumber

When in invoice.tpl where you want vat number to appear add:

{$vatnumber}

OR

 

just in your backend on Countries, near Address format:

write: vat_number

And vat number will appear near customer address..

Edited by augis2003 (see edit history)

Share this post


Link to post
Share on other sites

Hello

 

I like your PDF-Invoice.

 

But i have some errors (see the image pdf.jpg). for every text we have a ? sign. How can we remove it?

We have our shop in german.

 

Please post your invoice.tpl so that I can fix it. Or feel free to send it by PM.

Share this post


Link to post
Share on other sites

I am using version 1.4.9. Can anyone tell where the invoice.tpl file is located. Is it even called invoice.tpl in this version? If it has a different name can you  tell me what it is and where to find it?

Share this post


Link to post
Share on other sites

Hi, anybody knows how to display other dates than the date of order? I need to display the date when invoice was generated or at least date when payment was accepted.

 

List of all variables avalible in $order will be handy.

 

Thanks,

 

 

EDIT:

 

Found it.

{$order->invoice_date|date_format:"%d-%m-%Y %H:%M"} 

 

All avalible variables are in classes/order/Order.php  :unsure:

Edited by benyv6 (see edit history)

Share this post


Link to post
Share on other sites

Thanks for this guide I am really happy with this invoice and works perfect.

 

Now i am trying to get the same layout on the delivery slip for returning items but with no succes.

 

Does someone using this layout also for the delivery slip (return invoice) and can help me to get it right?

 

 

Share this post


Link to post
Share on other sites

I like to fold my invoices as they're printed and would like the customer order comments to show up below the invoice number (or besides the billing\shipping address)  instead of at the bottom of the invoice.  How can I move it?  Thanks.  Using PS default them for 1.5.2

 

Nevermind,  I figured it out.  BTW guys, if you open your invoice with Word you can test your changes before you upload them back to your PS install. 

 

Here's my modified invoice.tpl with the Order Notes moved to below the address.  I also lightened the background border and changed the text color to black in order to save on ink.

invoice.txt

Edited by MassiveRC (see edit history)

Share this post


Link to post
Share on other sites

i would like to know as well how to remove the (empty) header.tpl margin

 

[sOLVED]

Found the solution myself.

Goto /classes/pdf/PDFgenerator.php

 

Around line 155 you will see

 

$this->setMargins(10, 40, 10);
Change it to

 

$this->setMargins(10, 10, 10);

Save my Day buddy ;) thanks

Share this post


Link to post
Share on other sites

Hi!

 

I have searched for a couple of days now for a specific solution for my Invoice problem, but no luck.

 

In my invoice, billing and delivery address shows like this:

John Doe

Company Ltd. (optional)

34567890 (if company is filled also Vat number) 

Address Street 15

5000 Citiy

Slovenia

30554466 (phone number)

 

Is it possible, to add some labels to numbers? like this:

John Doe

Company Ltd.

Vat no.: 34567890

Address Street 15

5000 City

Slovenia

Phone: 30554466

 

I was browsing through the invoice.tpl code and apparently invoice address is called from elsewhere. I see two solutions:

1. Find that elsewhere and add labels {l s='Vat no.' pdf='true'} and {l s='Phone' pdf='true'}.

2. Break apart (or replace) the {$invoice_address} into {$firstname} {$lastname} <br /> {$company} <br /> {l s='Vat no.' pdf='true'} :{$vat_number} <br /> {$address1} <br /> {address2} <br /> {$postcode} {$city} <br /> {$countryName} <br />  {l s='Phone' pdf='true'}: {$phone_number}

 

Can someone point me in the right direction? I really need this fixed because of the laws and accounting issuies such unmarked numbers bring.

  • Like 1

Share this post


Link to post
Share on other sites

Hi  :)

 

First of all thanks for your time, you are great!

I do have a little problem.

 

I'm from Slovenia and in my store I'm using Slovenian language, which has characters like "č, š, ž, đ, ..." but i get question marks, when this characters are used.

 

How could i set UTF-8 encoding?

 

That might solve this problem, i guess ...

 

Regards, Housy

Share this post


Link to post
Share on other sites

Housy,

 

On our site we solved the problem by using different font. I reccomend Trebuchet MS, Arial or other fonts, that are commonly used on web to display Slovenian language properly. UTF-8 encoding usually comes enabled as standard option in Prestashop. Also in your BackOffice make sure you change Administration language to Slovenian - this is very important! (Translations are a disaster, but with some elbow grease, you can translate what you think you need)

 

When testing out fonts, make sure the € sign also remains normal. In some cases fonts start displaying čšćđž, but € character gets lost.

 

I hope this helps :)

Share this post


Link to post
Share on other sites

Hi ZaLuno,

 

i have changed charset to "freeserif" and it is ok for now. I'm gonna use other font as you suggested.

 

Thanks ;)

Housy

 

Housy,

 

On our site we solved the problem by using different font. I reccomend Trebuchet MS, Arial or other fonts, that are commonly used on web to display Slovenian language properly. UTF-8 encoding usually comes enabled as standard option in Prestashop. Also in your BackOffice make sure you change Administration language to Slovenian - this is very important! (Translations are a disaster, but with some elbow grease, you can translate what you think you need)

 

When testing out fonts, make sure the € sign also remains normal. In some cases fonts start displaying čšćđž, but € character gets lost.

 

I hope this helps :)

Share this post


Link to post
Share on other sites

How can i make the deliveryadress alwas stay on the right side?

 

I use a Single Integrated Label Style C so deliveryadress must stay on same place.

 

Using 1.5.6.0 orginal .tmpl

 

 

----------

 

I solved it my self.

Edited by mbp (see edit history)

Share this post


Link to post
Share on other sites

Is it possible, to add some labels to numbers? like this:

John Doe

Company Ltd.

Vat no.: 34567890

Address Street 15

5000 City

Slovenia

Phone: 30554466

 

I was browsing through the invoice.tpl code and apparently invoice address is called from elsewhere. I see two solutions:

1. Find that elsewhere and add labels {l s='Vat no.' pdf='true'} and {l s='Phone' pdf='true'}.

2. Break apart (or replace) the {$invoice_address} into {$firstname} {$lastname} <br /> {$company} <br /> {l s='Vat no.' pdf='true'} :{$vat_number} <br /> {$address1} <br /> {address2} <br /> {$postcode} {$city} <br /> {$countryName} <br />  {l s='Phone' pdf='true'}: {$phone_number}

 

Can someone point me in the right direction? I really need this fixed because of the laws and accounting issuies such unmarked numbers bring.

Please anyone? This is very important and I believe that I am not the only user needing this ...

Share this post


Link to post
Share on other sites

@MerseyRay

instead of using this

 

<tr>
<td style="width: 50%; text-align: right">Invoice Number :</td>
<td style="text-align: left">{$title|replace:'Invoice #':'':'htmlall':'UTF-8'}</td>
</tr>

 

try

<tr>
<td style="text-align: left">{$title|replace:'Invoice #':'Invoice Number :':'htmlall':'UTF-8'}</td>
</tr>

I think the replace function is better off ...

Share this post


Link to post
Share on other sites

Hi

Got a problem. I have placed an img src html code in pdf/invoice.tpl (and the image itself in the same folder).

And then got the error "TCPDF ERROR: [image] Unable to get image: 8x8t.gif" in BO orders.

Then I removed the image coding in invoice.tpl, expecting the error to disappear, but it didn't..!

 

Pls, what to do?

 

Ver. 1.5.4.1

 

Lee

Share this post


Link to post
Share on other sites

Everything went ok as per the solution provided , I was curious if we can have Serial Number of Products in Product Tab List (Right Aligned) and some good CSS so that it looks a real professional Invoice

Share this post


Link to post
Share on other sites

Hi

Got a problem. I have placed an img src html code in pdf/invoice.tpl (and the image itself in the same folder).

And then got the error "TCPDF ERROR: [image] Unable to get image: 8x8t.gif" in BO orders.

Then I removed the image coding in invoice.tpl, expecting the error to disappear, but it didn't..!

 

Pls, what to do?

 

Ver. 1.5.4.1

 

Lee

clear cache?

Share this post


Link to post
Share on other sites
  • 3 weeks later...
Hello!

how can i add shop info to the invoice!

I found these variables

 e.g.: 

 

{$shop_address|escape:'htmlall':'UTF-8'}

{$shop_details|escape:'htmlall':'UTF-8'}

 

... but every info appear in one line. 

 

I would like to see the values:

shop name

address

tel:

fax:

etc:

which variable can i get these info ?

Share this post


Link to post
Share on other sites
  • 2 weeks later...

Hello every one,

 

In Orders->Invoices menu when we generate pdf  file by date at that time all orders between two dates are printed in invoice file.

what i want is show a All Order Total: variable at the last page of the pdf and show there all orders total.

 

Thanks,

Ganesh

Share this post


Link to post
Share on other sites
Hello! 

workaround for the #141 problem!

In the suitable place I inserted this: {$shop_address|replace:'-':"<br>"}

Because the {$shop_address} variable contain the info "-" separated, thus the above modifier will brake new line the info !

Share this post


Link to post
Share on other sites
  • 1 month later...

I'd like to use the country iso code on the invoice.tpl file, taking advantage of the "country" object already declared in the "HTMLTemplateInvoice" file, though assigning the "iso code" to smarty crashes the pdf generation.

 

Any clue on how to properly send the iso code value to the tpl file?

Edited by shroom (see edit history)

Share this post


Link to post
Share on other sites

Hi everybody,

 

All those usefull informations helped me a lot, thank you!

 

But I have a very weird issue with PDF invoice. The euro symbol and sometimes french accents doesn't displays correctly. I spent five hours to search a solution for this issue and didn't find it. So I hope that you can help me. Firstly, I thought that is because I've made some changes to the template, so I've installed a new fresh version of prestashop 1.5.6.2 without any modifications, but the problem was the same. I've looked in the Php admin, the table are well coded un UTF-8, the prices displays correctly on front office, but not in the invoice... You can see the picture attached bellow of this issue.

 

Can you tell me, please, how to solve this issue?

 

post-144061-0-62093700-1393268379_thumb.png

Edited by kalakrima (see edit history)

Share this post


Link to post
Share on other sites

Hi everybody,

 

All those usefull informations helped me a lot, thank you!

 

But I have a very weird issue with PDF invoice. The euro symbol and sometimes french accents doesn't displays correctly. I spent five hours to search a solution for this issue and didn't find it. So I hope that you can help me. Firstly, I thought that is because I've made some changes to the template, so I've installed a new fresh version of prestashop 1.5.6.2 without any modifications, but the problem was the same. I've looked in the Php admin, the table are well coded un UTF-8, the prices displays correctly on front office, but not in the invoice... You can see the picture attached bellow of this issue.

 

Can you tell me, please, how to solve this issue?

 

 

Ok, it's really weird... When I open my file with other program then Acrobat, everything seems ok, but when I'm opening it with Acrobat, my currency symbol is replaced by this weird sign.. Somebody know how to fix this? My acrobat version is the last.

Share this post


Link to post
Share on other sites

PDF files can contain fonts used in the document. Sometimes just trust PDF reader that fonts are already installed.

 

This issue is about the fonts. Used, enclosed, installed. Search this way.

 

A small note. The M4 PDF Extensions module always include fonts for all characters in document. Then there are absolutely no problems with fonts.

Share this post


Link to post
Share on other sites

PDF files can contain fonts used in the document. Sometimes just trust PDF reader that fonts are already installed.

 

This issue is about the fonts. Used, enclosed, installed. Search this way.

 

A small note. The M4 PDF Extensions module always include fonts for all characters in document. Then there are absolutely no problems with fonts.

 

Hi, thank you for your help. I resolved the problem with Acrobat by setting "dejavusans" font by default for PDF Generator. May be this could help anyone in my case. :)

Share this post


Link to post
Share on other sites

hi rhapsody,

 

can i use the same solution for prestashop 1.5.6.1 , i have tried your solution but i am not getting anything... can you provide the solution..

 

what i did is ?

 

override the htmltemplateinvoice file, and posted the message display value in pdf/invoice.tpl file, but i am not getting the customer comments in invoice..

Edited by karthik who_am_i (see edit history)

Share this post


Link to post
Share on other sites

hi rhapsody,

 

can i use the same solution for prestashop 1.5.6.1 , i have tried your solution but i am not getting anything... can you provide the solution..

 

what i did is ?

 

override the htmltemplateinvoice file, and posted the message display value in pdf/invoice.tpl file, but i am not getting the customer comments in invoice..

I am using this solution on 1.5.6.2 and previously on 1.5.6.1 with no problem.  Did you clear your cache and recompile using the BO under advanced options, performance?

Share this post


Link to post
Share on other sites

Create the themes\your_theme_name\pdf and put any modified pdf template files there.  That way whenever you upgrade your changes will not be overwritten.

Share this post


Link to post
Share on other sites

Hi,

In Prestashop 1.5.6, on the current pdf invoice default model, one column is entitled "Product / Reference"
In such column :
- the item reference value is missing
- in the same cell, are the item title value and the attribute item value.

I would like to know how to have 3 distinct columns :
    - one column for item Reference
    - one column for item title
    - one column for item attribute

Thank you in advance for any reply.

Patrick

Share this post


Link to post
Share on other sites

How can i get customers email on invoice and/or packing slip.

 

I know how to get it in the adress field but i want it to display in some other area on invoice and slip.

 

{$customer->email}  does not work.

 

thanks in advance.

Share this post


Link to post
Share on other sites

Hi,

 

In Prestashop 1.5.6, on the current pdf invoice default model, one column is entitled "Product / Reference"

In such column :

- the item reference value is missing

- in the same cell, are the item title value and the attribute item value.

 

I would like to know how to have 3 distinct columns :

    - one column for item Reference

    - one column for item title

    - one column for item attribute

 

Thank you in advance for any reply.

 

Patrick

Ditto with Patrick on this one - the product reference used to appear in a separate column (PS v1.3) but after upgrading recently, my client is complaining that the product reference is now missing, so it's more difficult for her to be sure of the item ordered, at a glance.

 

See my next post for my solution

Edited by Torbz (see edit history)

Share this post


Link to post
Share on other sites

(Relevant to v.1.5.6.2)  

 

Ok, Patrick sussed it out:

 

In {install folder}/pdf/invoice.tpl is the following around line 129:

<!-- PRODUCTS -->
				{foreach $order_details as $order_detail}
				{cycle values='#FFF,#DDD' assign=bgcolor}
				<tr style="line-height:6px;background-color:{$bgcolor};">
					<td style="text-align: left; width: {if !$tax_excluded_display}35%{else}45%{/if}">{$order_detail.product_name}</td>
					<!-- unit price tax excluded is mandatory -->
					{if !$tax_excluded_display}
						<td style="text-align: right; width: 20%; white-space: nowrap;">
						{displayPrice currency=$order->id_currency price=$order_detail.unit_price_tax_excl}
						</td>

I then added this to line 133    (Ref. {$order_detail.product_reference})

 

e.g.

<td style="text-align: left; width: {if !$tax_excluded_display}35%{else}45%{/if}">{$order_detail.product_name} (Ref. {$order_detail.product_reference})</td>

which gave me the product reference at the end of the item description.

 

I know you want to create extra columns so you need to add a TD cell to the template around there to get the desired effect.

Edited by Torbz (see edit history)

Share this post


Link to post
Share on other sites
Hi,

 

Thank you to Torbz for the reply that worked well.

 

1- On the pdf invoice everything is translated into French except for the title of the column "Product".

I did not find where to translate Product into Produit

Any idea ?

 

2- On the pdf invoice is a column "Discount" (Réduction in French)

Is there a way to display this column only when a discount has been applied ?

 

Thank you in advance for any reply.

 

Patrick

Share this post


Link to post
Share on other sites
  • 2 weeks later...

The solution is in my Post #80 in this thread.

Thank you, works perfect! :)

One last question: html tags for bold text dont work, neither <b>, nor <strong>, not even <span style="font-weight: bold;">

Is that a common problem, or just mine?

Share this post


Link to post
Share on other sites

Hi Supremacy2k,

 

Thanks for sharing this guide.

 

Could you please tell me where I can delete below text in the pdf invoice?

It's about the VAT. I dont want it visible on the invoice.

 

 VAT details          VAT %             Total amount             Total amount

                                                       without VAT                  VAT

 

 

Thanks for your help!

Share this post


Link to post
Share on other sites
  • 2 weeks later...

hi! anyone knows how can i

  1. add in the Features in the product list
  2. add in Customer Name 
  3. add in Delivery Date & Time
  4. add in Order Status

in my Invoice. can anyone help me? thanks in advance :)

Share this post


Link to post
Share on other sites
  • 2 weeks later...

How can i get customers email on invoice and/or packing slip.

 

I know how to get it in the adress field but i want it to display in some other area on invoice and slip.

 

{$customer->email}  does not work.

 

thanks in advance.

 

I am trying to figure this one out too.  Did you have any success with this?

Share this post


Link to post
Share on other sites
  • 4 weeks later...

Hello guys, can anyone help me put an image/icon on my template? a already tried <img src='{$img_dir}mail.png' alt='mail'> and <img src='mail.png' alt='mail'> on the same directory, but nothing works, please i had my template 90% done.

 

 

Thanks in advance

post-756889-0-25055600-1400452937_thumb.png

Edited by mikemiranda (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

See the getLogo() function in the /classes/pdf/HTMLTemplate.php fiel how the full path for the logo is created.

Share this post


Link to post
Share on other sites

Include order number in header / Have the header on all pages

 

When using OP's solution for adding order number to the header of the PDF. Then the header doesn't show up on every page in the pdf but only the first.

 

I got a solution for this problem. So that you can have order number in the header and at the same time have the header appearing on all pages.

 

Step 1. In header.tpl do nothing! This could still be used for other PDF's than invoice.

 

Step 2. In invoice.tpl, add your header code at the top. Something like the content of header.tpl with order number added.

 

Step 3. In invoice.tpl, after your header code. Add this: <!-- END OF HEADER -->

 

The top of invoice.tpl could now look like this:

<table style="width: 100%">
<tr>
	<td style="width: 45%">
		{if $logo_path}
			<img src="{$logo_path}" style="width:{$width_logo}px; height:{$height_logo}px;" />
		{/if}
	</td>
	<td style="width: 5%"> </td>
	<td style="width: 50%; text-align: right;">
		<table style="width: 100%">
			<tr>
				<td style="font-weight: bold; font-size: 14pt; color: #444; width: 100%">Invoice</td>
			</tr>
			<tr>
				<td style="font-size: 14pt; color: #9E9F9E"> </td>
			</tr>
			<tr>
				<td style="font-size: 14pt; color: #9E9F9E">{$order->getUniqReference()}</td>
			</tr>
		</table>
	</td>
</tr>
</table>
<!-- END OF HEADER -->
<!-- ADDRESSES -->
<table ...

Step 4. In /override/classes/pdf/PDFGenerator.php add the function createContent() like below:

<?php

class PDFGenerator extends PDFGeneratorCore
{
	
	/**
	 *
	 * create the PDF content
	 * @param string $content HTML
	 */
	/*
		Override: if header is provided in content, override the header
	*/
	public function createContent($content)
	{
		
		$pieces = explode('<!-- END OF HEADER -->', $content, 2);
		
		if( count($pieces) == 2 ) {
			$this->header = $pieces[0];
			$this->content = $pieces[1];
		}
		else {
			$this->content = $content;
		}
	}
	
}

Done! :)

Share this post


Link to post
Share on other sites
  • 3 weeks later...
  • 3 weeks later...

Hi Supremacy2k, you have done an awesome job with this tutorial! I do have a few questions, though, I hope you can help me with below questions.

 

Attached is the invoice as it is set up now, what I want to change is the following:

 

1) The unit price "tax excl.GST " on one line (GST jumped to the line below) - so the same as Price (Incl. GST) and Total (Tax Incl.)

2) That same line with a grey background

3) The block with "Tax Details" - "tax rate" etc further down, it's too close to the actual invoice and doesn't look good (imo)

 

Thanks a lot

 

Sam

 

 

057.pdf

Share this post


Link to post
Share on other sites
  • 1 month later...

Solved: How can customer messages be displayed in the pdf invoice?

Jump to the bottom of this post for the solution - thanks to pointers from Bellini13!

 

I'm looking for the method to display messages on the pdf invoice that are displayed in the order history and the BO order display. In the front office when a customer selects order history in the "My Account" block, the messages are displayed when they click on "details" in the order history table. This lead me to look at the code in order-details.tpl that displays the data on the screen. Below is that code that I tried to paste in the invoice.tpl file, but it didn't work. Any ideas how to make the messages display in the pdf invoice?

{if count($messages)}
<h3>{l s='Messages'}</h3>
<div class="table_block">
  <table class="detail_step_by_step std">
   <thead>
	<tr>
	 <th class="first_item" style="width:150px;">{l s='From'}</th>
	 <th class="last_item">{l s='Message'}</th>
	</tr>
   </thead>
   <tbody>
   {foreach from=$messages item=message name="messageList"}
	<tr class="{if $smarty.foreach.messageList.first}first_item{elseif $smarty.foreach.messageList.last}last_item{/if} {if $smarty.foreach.messageList.index % 2}alternate_item{else}item{/if}">
	 <td>
	  {if isset($message.elastname) && $message.elastname}
	   {$message.efirstname|escape:'htmlall':'UTF-8'} {$message.elastname|escape:'htmlall':'UTF-8'}
	  {elseif $message.clastname}
	   {$message.cfirstname|escape:'htmlall':'UTF-8'} {$message.clastname|escape:'htmlall':'UTF-8'}
	  {else}
	   <b>{$shop_name|escape:'htmlall':'UTF-8'}</b>
	  {/if}
	  <br />
	  {dateFormat date=$message.date_add full=1}
	 </td>
	 <td>{$message.message|escape:'htmlall':'UTF-8'|nl2br}</td>
	</tr>
   {/foreach}
   </tbody>
  </table>
</div>
{/if}

The solution:

1. Override the HTMLTemplateInvoice.php using the code below to place the customer messages in Smarty. This will lookup the messages, place assign them into smarty, and then return the standard invoice getContent. The file should be placed in the override/classes/pdf directory.

<?php
/*
* Override for 1.5.4.1 HTMLTemplateInvoice.php to get order messages so they can be displayed in pdf invoice
*/

class HTMLTemplateInvoice extends HTMLTemplateInvoiceCore
{
public function getContent()
    {
		 $this->smarty->assign(array(
		 'order' => $this->order,
				    'messages' => CustomerMessage::getMessagesByOrderId((int)($this->order->id), false),
		 ));
		    return parent::getContent();
   }
}
2. Insert the following code in the theme/pdf/invoice.tpl file. The location depends where you want the comments to display. For my invoice the code was inserted just before

</table>
<!-- / PRODUCTS TAB -->
so the comments were displayed as the last item after the other sections of the invoice.

<!-- / CUSTOMER MESSAGES -->
   <tbody>
   {if $messages} <b>Order Messages</b>
   {foreach from=$messages item=message name="messageList"}
    <tr class="{if $smarty.foreach.messageList.first}first_item{elseif $smarty.foreach.messageList.last}last_item{/if} {if $smarty.foreach.messageList.index % 2}alternate_item{else}item{/if}">
	  <hr><td>
	  {if isset($message.elastname) && $message.elastname}
	   {$message.efirstname|escape:'htmlall':'UTF-8'} {$message.elastname|escape:'htmlall':'UTF-8'}
	  {elseif $message.clastname}
	   {$message.cfirstname|escape:'htmlall':'UTF-8'} {$message.clastname|escape:'htmlall':'UTF-8'}
	  {else}
	   <b>{$shop_name|escape:'htmlall':'UTF-8'}</b>
	  {/if}
	  <br />
	  {dateFormat date=$message.date_add full=1}
	 </td>
	 <td>{$message.message|escape:'htmlall':'UTF-8'|nl2br}</td>
    </tr>
   {/foreach}
   {/if}
   </tbody>
<!-- / CUSTOMER MESSAGES -->

I need to do that in Prestashop 1.6. I added these code but not work, what can I do?

Share this post


Link to post
Share on other sites
  • 5 weeks later...

Hello everybody,

 

I try to put a bakckground image on my invoice but it seem that it is deleted when the pdf is generated. Somebody can help me to do that?

 

I did this on 1.6  : 

<div style="font-size: 8pt; color: #444; background-image: url('img/back_invoice3.png');">

<table>
	<tr><td> </td></tr>
</table>

thank you verryu much !

Share this post


Link to post
Share on other sites