Jump to content
  • 0
JLund96

[Guide] Modifying Prestashop 1.5 Invoice Template.

Question

272 answers to this 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

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

×