Jump to content
  • 0
JLund96

[Guide] Modifying Prestashop 1.5/1.6 Invoice Template.

Question

Recommended Posts

  • 0

Super thank you. I now have a very nice looking invoice :-)

 

However i have a bit too much space above the logo. How do i decrease this?

 

Thanks.

 

Anders

Share this post


Link to post
Share on other sites
  • 0

Footer files are not altered. You can find them in your PDF folder.

 

In the top of this guide is a list of files that is subject to changes. :-)

Share this post


Link to post
Share on other sites
  • 0

how can I change {$invoice_address} and {$delivery_address} format.

 

 

Company name (bold) or font size 18

firstname lastname (small)

address1, address2

city, country

 

actually I need this format on every document

Edited by Jamshaid Hashmi

Share this post


Link to post
Share on other sites
  • 0

After copy the code in my invoice.tpl i became this error:

 

Warning: Division by zero in /www/htdocs/....../....../....../....../tools/tcpdf/tcpdf.php on line 23203

 

Warning: array_fill() [function.array-fill]: Number of elements must be positive in /www/htdocs/....../....../....../....../tools/tcpdf/tcpdf.phpon line 23205

 

Warning: Invalid argument supplied for foreach() in /www/htdocs/....../....../....../....../tools/tcpdf/tcpdf.php on line 24618

 

Warning: Invalid argument supplied for foreach() in /www/htdocs/....../....../....../....../tools/tcpdf/tcpdf.php on line 24650

TCPDF ERROR: Some data has already been output, can't send PDF file

Edited by m3442a

Share this post


Link to post
Share on other sites
  • 0

Well then its at 1.4 upgraded to 1.5, because 1.5 do not have a "tools" folder.

 

And in that case I'm not sure what your problem is, because I'm not getting any errors on my shop, which is live. :/

 

Edit: I can see you get your error in the .php file, and not the tpl file.

Edited by Supremacy2k

Share this post


Link to post
Share on other sites
  • 0

very nice guide, thanks for sharing!

 

v1.5 does indeed include a tools folder, which is where all the plugins and 3rd party libraries are stored. The error is occuring in the writeHTML function of tcpdf.php. Most likely something in the invoice.tpl is not correct or conflicting with the users specific installation. It would need to be debugged further to understand the problem.

Share this post


Link to post
Share on other sites
  • 0

Okey I'm blind.

I totally missed the "tools" folder, hehe.

 

Anyways.

 

On line 23.203 i have the following:

} else {

on 23.205 i have this:

}

On 24.618 this:

$this->y += $this->getHTMLUnitToUnits($table_el['attribute']['cellspacing'], 1, 'px');

and on 24.650 this

if (isset($this->theadMargins['top'])) {

 

m3442a .. can you post your lines from 24203 to 24205 and from 24618 to 24650 ?

Share this post


Link to post
Share on other sites
  • 0

how can I change {$invoice_address} and {$delivery_address} format.

 

 

Company name (bold) or font size 18

firstname lastname (small)

address1, address2

city, country

 

actually I need this format on every document

 

To be honest I'm not quite sure where address text is generated.

I havent looked into it, and might go beyond my skills for now. :(

Share this post


Link to post
Share on other sites
  • 0

on line 176 :

<td  style="text-align: left; width: 10%;">{$order_detail.product_ean13}</td>

 

insert :

<td  style="text-align: left; width: 10%;">{$order_detail.product_reference}</td>

 

should do it. :)

Share this post


Link to post
Share on other sites
  • 0

thanks Supremacy2k for your guide

 

Hi,

 

I used a little info from this topic, attached my result.

 

Wouter

hi, do you think that you can post your files with adaptation? thank you

Share this post


Link to post
Share on other sites
  • 0

Hi,

 

I made some alterations to my invoice also. But at the reference number/order number I can't make that show.

I tried inseting

{$order_detail.product_reference}

but on the PDF I see only a blank space and then I looked at your guide and tried with

{$order_detail.product_ean13}

.

 

The result is the same. I don't understand what I did wrong with the invoice template because all the other cells and data in them are shown properly.

 

Can anybody give me some pointers to what should I try next?

 

Thanks

Share this post


Link to post
Share on other sites
  • 0

hmm wierd... it should work.

 

I got a lot of work the next week or so, but im not gonna forget your question, and i will get back to you.

Share this post


Link to post
Share on other sites
  • 0

Hi

 

I have the same problem with EAN codes - it is blank. All other fields are fine. Latest stable PrestShop.

Hi,

 

I made some alterations to my invoice also. But at the reference number/order number I can't make that show.

I tried inseting

{$order_detail.product_reference}

but on the PDF I see only a blank space and then I looked at your guide and tried with

{$order_detail.product_ean13}

.

 

The result is the same. I don't understand what I did wrong with the invoice template because all the other cells and data in them are shown properly.

 

Can anybody give me some pointers to what should I try next?

 

Thanks

Share this post


Link to post
Share on other sites
  • 0

are you both sure you actually have something written in either reference or ean13 for your products?

Edited by Supremacy2k

Share this post


Link to post
Share on other sites
  • 0

Kris,

 

 

Do you know how to change the total price position to the bottom. I've try to amend invoice.tpl but it only works in the first page, if there is 2nd page or above, it's not at the bottom.

 

You can see the attachment for reference.

 

 

post-442650-0-03861600-1359967834_thumb.jpg

 

 

I'm using PS 1.5

 

Pls help :unsure:

 

Thank you

Share this post


Link to post
Share on other sites
  • 0

Hi,

 

I've the same problem, I want to mpdify my invoice template but it's not very pretty. the TCPDF don't say about margin padding ...

 

cdlt

Share this post


Link to post
Share on other sites
  • 0

And if i want to show a feature value of the product named "idacs" instead the {$order_detail.product_reference}???

Edited by infinityl

Share this post


Link to post
Share on other sites
  • 0

Hi guys.

 

Thanks for your patience.

I would like you all to post a comment with your invoice files.

 

and i will go over them in the weekend, and test them ofc.

 

- Kris.

Share this post


Link to post
Share on other sites
  • 0

OMG, Supremacy2k, you've just made my day!!

 

Saved me a lot of time (and coffee lol). Just a few changes left and it's perfect for me in Germany.

Many many thx.

 

Rainer

Share this post


Link to post
Share on other sites
  • 0

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);

Edited by John_John

Share this post


Link to post
Share on other sites
  • 0

Found a similar solution in the french forum:

http://www.prestasho...-prestashop-15/

 

This version contains a section for display weight, carrier and tracking ID I used just as option for my own slightly modified invoice.tpl, which is attached as pdf.

(Full coding you find here: http://www.prestasho...36#entry1117036 )

 

<!-- Optional display of weight, carrier and tracking ID -->

{foreach from=$order->getShipping() item=shipping name=shippingsLoop}
<table style="width: 100%; text-align: center; border: 1px solid #CCC; font-size: 9pt;">
 <tr>
  <td colspan = "3" style="background-color: #CCC; color: #000;">
	<b>{l s='Paket Nr. ' pdf='true'}{$smarty.foreach.shippingsLoop.iteration}</b>
  </td>
 </tr>
 <tr>
  <td style="width: 33%; background-color: #EEE; color: #000;">
	<b>{l s='Gewicht:' pdf='true'}</b>
  </td>
  <td style="width: 33%; background-color: #EEE; color: #000;">
	<b>{l s='Versanddienst:' pdf='true'}</b>
  </td>
  <td style="width: 34%; background-color: #EEE; color: #000;">
	<b>{l s='Tracking-Nr.:' pdf='true'}</b>
  </td>
 </tr>
 <tr>
  <td style="width: 33%;">
	{$shipping.weight|string_format:"%.3f"} Kg
  </td>
  <td style="width: 33%;">
	{$shipping.state_name}
  </td>
  <td style="width: 34%;">
	{$shipping.tracking_number}
  </td>
 </tr>
</table>
{/foreach}

 

For printouts on own business paper I recommend just to deactivate line 73 and 74 in /classes/pdf/pdf.php with /* ... */:

 

$this->pdf_renderer->createHeader($template->getHeader());
$this->pdf_renderer->createFooter($template->getFooter());

 

If the billing address doesn't fit, either change the margins in /classes/pdf/PDFgenerator.php or

adjust table width from 100% to about 92%, which matches about 1in for left margin.

 

Anyhow, as our tax laws in Germany are very complicated, I got an urgent request too:

Does anybody know how to display the tax rate for each product in every line of the invoice's products section?

 

It's jinxed, but I just can't manage it. I really have no idea.

Edited by eleazar

Share this post


Link to post
Share on other sites
  • 0

Why not? If you're desperate to include the reference to any particular style in the invoice.tpl, it should work.

 

Maybe even with a separate css file if you activate option Smart Cache for CSS. This forces PrestaShop to conbine all css files into a single file.

Edited by eleazar

Share this post


Link to post
Share on other sites
  • 0

Anyhow, as our tax laws in Germany are very complicated, I got an urgent request too:

Does anybody know how to display the tax rate for each product in every line of the invoice's products section?

 

It's jinxed, but I just can't manage it. I really have no idea.

 

you could have a look into the template of ps1.4 (if nobody changed the name of the methods/functions for 1.5)

Edited by andrep

Share this post


Link to post
Share on other sites
  • 0

Why not? If you're desperate to include the reference to any particular style in the invoice.tpl, it should work.

 

Maybe even with a separate css file if you activate option Smart Cache for CSS. This forces PrestaShop to conbine all css files into a single file.

 

didn't try with smart cache for CSS (I already started coding the template without it), but without didn't work

Share this post


Link to post
Share on other sites
  • 0

Does anyone know of anyone sharing their customised invoice templates?

Be nice if there was some nice looking ones already made that people were willing to share, could save me some time! :P

Share this post


Link to post
Share on other sites
  • 0

Does anyone know of anyone sharing their customised invoice templates?

Be nice if there was some nice looking ones already made that people were willing to share, could save me some time! :P

 

Here we are

 

if you want you can share your work on this page

Edited by andrep

Share this post


Link to post
Share on other sites
  • 0

With the modifications explained in the OP, this removes the content from the header.tpl file and inserts it into the invoice.tpl file.

That's fine, however the invoice then has a large gap at the top where the header should be, since the header file is now empty.

 

Is there any way to move the invoice.tpl content higher to the top of the page, i.e. reduce the height of the header.tpl allowance within the PDF?

Share this post


Link to post
Share on other sites
  • 0

I'll been fighting with this my self.

 

The reason why i chose to move the header content into the main document, was because the header.tpl don't have access to all variables used with this invoice template.

 

The major factor was the order number.

 

How to either remove the header.tpl from this template or reduces it's occupied space on the pdf, i don't know. :(

Share this post


Link to post
Share on other sites
  • 0

@cammo & Supremacy2k

 

Is there any way to move the invoice.tpl content higher to the top of the page, i.e. reduce the height of the header.tpl allowance within the PDF?

 

How to either remove the header.tpl from this template or reduces it's occupied space on the pdf, i don't know

 

So once again what JohnJohn already posted on page 2 of this thread:

 

You may reduce space for header or footer in lines 153 and 154 of /classes/pdf/PDFgenerator.php:

 

 * Write a PDF page
 */
public function writePage()
{
 $this->SetHeaderMargin(5);
 $this->SetFooterMargin(18);
 $this->setMargins(10, 40, 10);
 $this->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM);

 $this->AddPage();

 $this->writeHTML($this->content, true, false, true, false, '');
}

Share this post


Link to post
Share on other sites
  • 0

So to do an override of the PDFgenerator.php class, do I simply duplicate the file into the overrides folder override\classes\pdf\ and make my modifications, or do you simply put the modified bit of code into the override file?

Share this post


Link to post
Share on other sites
  • 0

No, don't just duplicate the file! You need to replace

 

class PDFGeneratorCore extends TCPDF

 

with this line already written in the overrrides file:

 

class PDFGenerator extends PDFGeneratorCore

 

With this modifications you may copy the whole file to /overrides/pdf.

 

Or you just modify the funktion with an overrides file containing just the function with your range modification like shown below:

 

<?
class PDFGenerator extends PDFGeneratorCore
{
* Write a PDF page
 */
public function writePage()
{
 $this->SetHeaderMargin(5);
 $this->SetFooterMargin(18);
 $this->setMargins(10, 40, 10);
 $this->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM);
 $this->AddPage();
 $this->writeHTML($this->content, true, false, true, false, '');
}
}

 

Full modified copy does work, in case of the second I'm not quite sure. Normally I use the full mode.

Edited by eleazar

Share this post


Link to post
Share on other sites
  • 0

@ Supremacy2k: Thanks a lot for this guide, it made my day. :-)

 

A related question: Does anyone know how I can add the customers phone number to the pdf invoice? I'm using v. 1.5.3.1

 

I have tried editing the address format in "cuntries" but it doesn't seem to do anything.

Share this post


Link to post
Share on other sites
  • 0

@dklap3

 

Sounds weird.

 

I think you should

  • either delete the smarty cache in \cache\smarty\cache and \cache\smarty\compile
  • or switch for one time to Force compile in Advanced Parameters second menu item in section Smarty.
    (Then switch back to normal mode. Slows down your shop system)

 

Then your modifications should work.

Share this post


Link to post
Share on other sites
  • 0

@ eleazer: thank you for the reply. I think I found the problem.

 

In "country", when trying to add the phone, I clicked "Address" > "phone_mobile" which added a "Address:phone_mobile" to the format field. This didn't show up on my invoice. However, deleting the first part and just writing "phone_mobile" made it show up..not sure why but a bit confusing. Anyway it works now. :)

 

On last thing: Do you also know if I can possibly add a little "(Tlf)", or any other text, after or before the phone number? My adress format includes 2 things with 8 numbers (phone and tax nr.) and I would like to add such a little text next to them to avoid confusion.

Share this post


Link to post
Share on other sites
  • 0

Nope, inserting other text isn't allowed here. Just the field names. And in future you should better klick on the button "Apply standard" or something like that (sorry, but my buttons are in German) displayed below the field as second one. This forces PrestaShop to dislplay all valid field names and you avoid misspelling.

 

Anyhow, it should be possible to add some text to the billing or delivery address, but that's a bit tricky because you have to modify the core file where the address formats are generated.

PDFs in PrestaShop just display these elsewhere generated address formats.

Share this post


Link to post
Share on other sites
  • 0

Thank you again for the answer eleazar.

 

I might try to modify the core files later, but for now I found another more simple solution.

 

For my new invoice (based on the example in this thread), I have just added the text manually in the <td> next to the address. All the fields in the address are mandatory, so I'm sure it will be the same fields used every time.

 

It's in Danish, but you'll probably get it:

 

faktura.jpg

Share this post


Link to post
Share on other sites
  • 0

hello

 

Is there a way to sort products by

1) category

2) by name

3) and then price .

 

am looking to simply filling orders by having tiese sorts on invoice for picking purposes.

 

Thank you for any help in this matter

Share this post


Link to post
Share on other sites
  • 0

Great post. Learned a lot today... Even though still a newbie managed to fit the adresses to work with my peel of labels and did some other design changes. Although the one thing I can not seam to find and modify is the the table with total tax under the product table? I see something called {$tax_tab} but not sure how to modify. I primarily would like to adjust the background for the titles and potentially move it.

A perfect continuation of this guide/post would be some guidence how to modify the delivery slip as well? Although after this guide I feel confident enough to have a look at least... :)

Share this post


Link to post
Share on other sites
  • 0

Great Info here! I learned so much!

 

Quick question:

 

Anyone know how to create seperate invoices for different countries and have the system recognize this? I would be interested in having two seperate types of invoices, one for my clients in Switz and the others for Germany/ france.

 

Thanks!

Share this post


Link to post
Share on other sites
  • 0

Do you know how to create invoices only for a specific customer group? or avoid to create invoices for a specific customer group?

Share this post


Link to post
Share on other sites
  • 0

What do I need to modify to have one invoice template in FO and another invoice template in BO.

Obviously, I know that I need 2 templates.

Share this post


Link to post
Share on other sites
  • 0

I have found this post very useful. Currently when I upgrade Prestashop, I keep a folder on my local drive that includes the modified .tpl files to upload into the PDF directory after an upgrade. I was wondering if it would be possible to create a PDF directory in my custom theme directory that inludes the .tpl files, then have an Override file in override/classes/pdf that would force the PDF generation to pickup the modified template files in my custom theme? That would simplify upgrading for everyone.

 

Anybody care to take this on, or suggest a similar approach so that autoupgrade doesn't overwrite the customized PDF files?

Share this post


Link to post
Share on other sites
  • 0

Hi Rhapsody,

why so complicated. ;)

It's totally simple. Just create the pdf directory in your custom themes directory.

The files you put here will automatically override the default PDF files. That's all. No additional change necessary.

 

Same solution possible for the mails directory, if you apply some modifications here, too.

Share this post


Link to post
Share on other sites
  • 0

Okey I'm blind.

I totally missed the "tools" folder, hehe.

 

Anyways.

 

On line 23.203 i have the following:

} else {

on 23.205 i have this:

}

On 24.618 this:

$this->y += $this->getHTMLUnitToUnits($table_el['attribute']['cellspacing'], 1, 'px');

and on 24.650 this

if (isset($this->theadMargins['top'])) {

 

m3442a .. can you post your lines from 24203 to 24205 and from 24618 to 24650 ?

this error is normal when there is a typo in your invoice.txt

<table style="width: 100%;">
<tr>
 <td style="width: 17%"></td>
  <td style="width: 66%">{if $available_in_your_account}{l s='An electronic version of this invoice is available in your account. To access it, log in to our website using your e-mail address and password (which you created when placing your first order).' pdf='true'}{/if}</td>
 </td style="width: 17%"></td>
</tr>
</table>  

You have a closing td instead of an opening td in the last td rule ;)

Share this post


Link to post
Share on other sites
  • 0

Does anybody know of you guys how I manage to add the gender to both invoice and delivery address, so that you get something like

 

Mrs

Ronda Nuttleback

,,,

 

in invoice.tpl

This really drives me mad because I don't know how to solve this problem and in Germany a personalized address format is the normal case.

Share this post


Link to post
Share on other sites
  • 0

I have some custom fields defined in the ps_customer table. In the old 1.4 PS I was able to include these in the PDF.php override file to have them display on the PDF invoice. Can I do similar using just the template files with 1.5? For example - the custom field names in the ps_customer table are member and spouse. If the customer purchase products with ID 6, 10, 15, 17 or 26 then display a section on the invoice that includes the custom fields.

 

Bellini helped me with this as on override for my custom invoice in PS 1.4. I'm doing other shop mods and getting ready to upgrade a shop from 1.4.10.0 to 1.5. The customized invoice is the last item I need to make work.

 

What I want to do is check if certain products were purchased, and if they were, display a section with the custom field names.

Share this post


Link to post
Share on other sites
  • 0

Hi, ramesh90,

just logo or complete header?

 

How-to for removing the complete header I already posted here:

http://www.prestashop.com/forums/index.php?/topic/213664-guide-modifying-prestashop-15-invoice-template/page__view__findpost__p__1119146

 

To remove just the logo you have to open /pdf/header.tpl and disable line 28-30 like this:

 

{*
{if $logo_path}
  <img src="{$logo_path}" style="width:{$width_logo}px; height:{$height_logo}px;" />
 {/if}
*}

Share this post


Link to post
Share on other sites
  • 0

guys how do i remove the top space from my invoice, that's the exact space for the old header which i removed

 

Hi desudura,

 

I guess you just deactivated the header printout in /classes/pdf/pdf.php by disabling the line

 

$this->pdf_renderer->createHeader($template->getHeader());

 

But by doing this a white space is the only result.

 

You need to modify function writePage() in /classes/pdf/PDFgenerator.php. Looks like this:

 

public function writePage()
{
 $this->SetHeaderMargin(5);
 $this->SetFooterMargin(18);
 $this->setMargins(10, 40, 10);
 $this->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM);
 $this->AddPage();
 $this->writeHTML($this->content, true, false, true, false, '');
}

 

Measures are in mm. You have to modify line 183 (v 1.5.3.x) or line 153 (v 1.5.4.x) to

 

$this->SetHeaderMargin(5);

 

if your measure is mm here. Search forfunction __construct. There must be a line like this:

 

parent::__construct('P', 'mm', 'A4', true, 'UTF-8', $use_cache, false);

 

If, as I don't know, your linear measurement is different, you got to modify this entry too.

 

If all this doesn't help I would guess that you didn't insert the framed text and logo of you header to header.tpl (where it belongs) but to invoice.tpl. If so, then move this complete table to header.tpl and replace the code in this file with your own header code.

Edited by eleazar

Share this post


Link to post
Share on other sites
  • 0

Okey I'm blind.

I totally missed the "tools" folder, hehe.

 

Anyways.

 

On line 23.203 i have the following:

} else {

on 23.205 i have this:

}

On 24.618 this:

$this->y += $this->getHTMLUnitToUnits($table_el['attribute']['cellspacing'], 1, 'px');

and on 24.650 this

if (isset($this->theadMargins['top'])) {

 

m3442a .. can you post your lines from 24203 to 24205 and from 24618 to 24650 ?

I have the same error.

Since m3442a haven't posted the lines, I would be happy to do it, if you're still are willing to help?

Share this post


Link to post
Share on other sites
  • 0

I have a strange problem, i've been using a really good looking invoice template cardscapital created and shared here but for some reason, it shows two carriers when i only have one carrier from back office.

 

It still shows "my carrier" first and below that my actual carrier..any ideas?

Share this post


Link to post
Share on other sites
  • 0

I have now customized my 1.5.4.1 invoice and added the special "logic" for the membership cards I wanted to include for printing when membership is purchased.

 

Has anyone figured out how to modify the display of product attributes? Currently it is a run on string with the attribute name, followed by a colon, then the attribute. I would like to display each attribute and value on a separate line, similar to the way product customizations are displayed.

Share this post


Link to post
Share on other sites
  • 0

[solved] How to make product attributes and groups (combinations in the BO for products) display on separate lines of the PDF invoice.

...

Has anyone figured out how to modify the display of product attributes? Currently it is a run on string with the attribute name, followed by a colon, then the attribute. I would like to display each attribute and value on a separate line, similar to the way product customizations are displayed.

I figured it out. The following can be put in the invoice.tpl file as a modification:

Search for:

<td style="text-align: left; width: 45%">{$order_detail.product_name}</td>

and replace with the following

<td style="text-align: left; width: 45%">{$order_detail.product_name|replace:', ':'<br>'|replace:' - ':'<br>'}</td>

This has the effect of making the product description display like this:

This is the product description with the assigned attributes

Attribute1 : Value 1

Attribute2 : Value2

Attribute3 : Value3

Attribute4 : Value4

 

instead of displaying like this:

This is the product description with the assigned attributes - Attribute1 : Value 1,

Attribute2 : Value2, Attribute3 : Value3, Attribute4 : Value4

Edited by Rhapsody

Share this post


Link to post
Share on other sites
  • 0

I'm trying to save on ink and want to lighten the black bars for Product/Reference and Tax Detail. I'd be happy just using a white background and having regular black lettering. Can some [spam-filter] tell me what fields to change if it's that easy? Thanks.

Share this post


Link to post
Share on other sites
  • 0

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

Edited by Rhapsody

Share this post


Link to post
Share on other sites
  • 0

Is there a way to show the attributes below the product name?

Or is there a smarty available to show the attributes separate?

 

Right now in invoice.tpl it's using: {$order_detail.product_name} and the product name and attributes are all in 1 line (very ugly)

Share this post


Link to post
Share on other sites
  • 0

Is there a way to show the attributes below the product name?

Or is there a smarty available to show the attributes separate?

 

Right now in invoice.tpl it's using: {$order_detail.product_name} and the product name and attributes are all in 1 line (very ugly)

 

see my post #78 in this thread with the solution.

Share this post


Link to post
Share on other sites
  • 0

Hi guys,

Does anyone know how to display the time next to date in the default invoice?

 

i tried to change

{dateFormat date=$order->date_add full=0}

into

{dateFormat date=$order->date_add|date_format:"%d-%m-%Y %H:%M"}

 

in invoice.tpl but it is not working

Share this post


Link to post
Share on other sites
  • 0

How do i rename tax excl. top of colom header-> Unit Price (Tax Excl.) colum title. to be only Unit Price

 

 

thx you all :rolleyes:

post-374708-0-72807800-1374382409_thumb.jpg

Edited by Bejo

Share this post


Link to post
Share on other sites
  • 0

please help how to rename page title of pdf invocie? i want to remove bold text -> Total (Tax Excl.) & Unit Price(Tax Excl.)

Share this post


Link to post
Share on other sites