Jump to content

How to edit PDF invoice content in PrestaShop 1.3.1


istox
 Share

Recommended Posts

Is it the information at the bottom of the invoice you want to change? If so, the code for it is at the bottom of the Footer() function in classes/PDF.php:

$this->Cell(0, 5, $conf['PS_SHOP_NAME_UPPER'].
(!empty($conf['PS_SHOP_ADDR1']) ? ' - '.self::l('Headquarters:').' '.$conf['PS_SHOP_ADDR1'].(!empty($conf['PS_SHOP_ADDR2']) ? ' '.$conf['PS_SHOP_ADDR2'] : '').' '.$conf['PS_SHOP_CODE'].' '.$conf['PS_SHOP_CITY'].((isset($conf['PS_SHOP_STATE']) AND !empty($conf['PS_SHOP_STATE'])) ? (', '.$conf['PS_SHOP_STATE']) : '').' '.$conf['PS_SHOP_COUNTRY'] : ''), 0, 1, 'C', 1);
$this->Cell(0, 5,
(!empty($conf['PS_SHOP_DETAILS']) ? self::l('Details:').' '.$conf['PS_SHOP_DETAILS'].' - ' : '').
(!empty($conf['PS_SHOP_PHONE']) ? self::l('PHONE:').' '.$conf['PS_SHOP_PHONE'] : ''), 0, 1, 'C', 1);



By default, it has the shop name, 'Headerquarters:' followed by the address, shop details and phone number. If you don't want to modify code, you can enter the extra information on the Preferences > Contact tab in the "Registration" text area.

Share this post


Link to post
Share on other sites

Thanks! But not in the bottom. In the bottom is everything Ok.

And I don't want to change. I want to insert new info. Just text in column.

I attached screenshot where i want to put my info.

Please help with the code of inserting. And advice the lines number...

29137_HxUYIC9grQ1ViiBasC2h_t

Share this post


Link to post
Share on other sites

To add the content below the addresses, you'll need to put the code before the /* display order information */ section one line 424 of classes/PDF.php (in PrestaShop v1.3.1). Add the following:

$pdf->Ln(5);
$pdf->Cell(0, 6, self::l('Put your content here'));

Share this post


Link to post
Share on other sites

  • 2 months later...
  • 2 weeks later...
  • 2 weeks later...

To remove "Total products (tax excl.)" and "Total (tax excl.)", you will need to /* comment out */ lines 480-486 of classes/PDF.php:

$pdf->Ln(5);
$pdf->SetFont(self::fontname(), 'B', 8);
$width = 165;
$pdf->Cell($width, 0, self::l('Total products (tax excl.)').' : ', 0, 0, 'R');
$pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($priceBreakDown['totalProductsWithoutTax'], self::$currency, true, false)), 0, 0, 'R');
$pdf->Ln(4);    



and lines 535-537:

$pdf->Cell($width, 0, self::l('Total').' '.(self::$_priceDisplayMethod == PS_TAX_EXC ? self::l(' (tax excl.)') : self::l(' (tax incl.)')).' : ', 0, 0, 'R');
$pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice((self::$_priceDisplayMethod == PS_TAX_EXC ? $priceBreakDown['totalWithoutTax'] : $priceBreakDown['totalWithTax']), self::$currency, true, false)), 0, 0, 'R');
$pdf->Ln(4);

Share this post


Link to post
Share on other sites

  • 5 weeks later...
  • 4 months later...

Hello,

I wondered which code to remove to display only:

total products (tax excl.)
total products (tax incl.)
total shipping
total (tax incl.)

So I want to get rid of the total of products and shipping tax excl.

Share this post


Link to post
Share on other sites

  • 2 weeks later...

Rocky, is this the new code in 1.4 which displays the address at the top of the invoice?
Does this code say not to show these things... ?

In V 1.2.5 we used to get the customers phone number displaying under the address, and now it does not show on pdf invoices (in 1.4).
Can you confirm how we can show the phone number please?

        $patternRules = array(
               'avoid' => array(
                   'address2',
                   'company',
                   'phone',
                   'phone_mobile'));

       $addressType = self::generateHeaderAddresses($pdf, $order, $addressType, $patternRules, $width);

Share this post


Link to post
Share on other sites

Yes, that's the code that sets what is displayed and then calls the generateHeaderAddresses() functions to display it. I just tried clicking on the PDF icon next to an order on my website and the phone number is displayed under the addresses. I don't understand why it isn't working for you.

Share this post


Link to post
Share on other sites

  • 1 month later...

How do you pull in a field from another table into the pdf. For example something from a custom module that I'd like to added which lives here:

 

table: ps_order_paymentcard

col: cardholdername

 

I tried an sql query and it only worked under the order tab and not the email, here's what I did:

 

 

$orderid1 = $order->id;

$result = mysql_query("SELECT * FROM ps_orders INNER JOIN ps_order_paymentcard ON ps_orders.id_order = ps_order_paymentcard.id_order WHERE ps_orders.id_order =  $orderid1") 
or die(mysql_error());   

$pdf->Cell($width, 10,  self::l('Customer order number:').$row['cardholdername']);

 

there must be an easier way to do what I'm trying to achieve.

 

Roger

Share this post


Link to post
Share on other sites

Yes, that's the code that sets what is displayed and then calls the generateHeaderAddresses() functions to display it. I just tried clicking on the PDF icon next to an order on my website and the phone number is displayed under the addresses. I don't understand why it isn't working for you.

Same problem for me with presta 1.4 (not in English language) - phone number is not shown in the invoice. Any solution ?

Also the state is not shown. I thought it was from the presta table ps_address_format but no .

Share this post


Link to post
Share on other sites

I just tried viewing some of the PDF invoices on my own PrestaShop v1.4.4.1 website and it displays the phone numbers underneath the addresses at the top. My classes/PDF.php file also has 'phone' in the 'avoid' variable, yet the phone number is displayed. Try going to Shipping > Countries, edit the customer's country and make sure the address layout has 'phone' at the end.

  • Like 1

Share this post


Link to post
Share on other sites

On Shipping -> Country for my country I had

firstname lastname

company

vat_number

address1

address2

postcode city

Country:name

phone

Now it's look like this

firstname lastname

company

vat_number

address1

address2

postcode city

State:name

Country:name

phone

phone_mobile

An it's working. Thank's for the tip. I was used to modify directly in the DB , I wasn't used to play with this area Shipping > Countries, where I found how exactly I had to put the state and mobile phone.For me the problem is [sOLVED]

Share this post


Link to post
Share on other sites

Is it the information at the bottom of the invoice you want to change? If so, the code for it is at the bottom of the Footer() function in classes/PDF.php:

$this->Cell(0, 5, $conf['PS_SHOP_NAME_UPPER'].
(!empty($conf['PS_SHOP_ADDR1']) ? ' - '.self::l('Headquarters:').' '.$conf['PS_SHOP_ADDR1'].(!empty($conf['PS_SHOP_ADDR2']) ? ' '.$conf['PS_SHOP_ADDR2'] : '').' '.$conf['PS_SHOP_CODE'].' '.$conf['PS_SHOP_CITY'].((isset($conf['PS_SHOP_STATE']) AND !empty($conf['PS_SHOP_STATE'])) ? (', '.$conf['PS_SHOP_STATE']) : '').' '.$conf['PS_SHOP_COUNTRY'] : ''), 0, 1, 'C', 1);
$this->Cell(0, 5,
(!empty($conf['PS_SHOP_DETAILS']) ? self::l('Details:').' '.$conf['PS_SHOP_DETAILS'].' - ' : '').
(!empty($conf['PS_SHOP_PHONE']) ? self::l('PHONE:').' '.$conf['PS_SHOP_PHONE'] : ''), 0, 1, 'C', 1);

By default, it has the shop name, 'Headerquarters:' followed by the address, shop details and phone number. If you don't want to modify code, you can enter the extra information on the Preferences > Contact tab in the "Registration" text area.

 

Great! This is very helpful, I applied it then it works fine.

Thanks for your help!

Share this post


Link to post
Share on other sites

  • 1 month later...

Hi Everybody,

 

I need help for 2 problems:

 

1- I have a problem with Tax detail. The Pre-tax total is incorrect. It seems to pick up the price of the last product instead on Total products (tax excl.). See image.

 

 

 

1- I wish to remove: Total products (tax incl.). I tried the method mentioned by Rocky (post #9) but it didn't work. Is there any other way?

Share this post


Link to post
Share on other sites

1- I wish to remove: Total products (tax incl.). I tried the method mentioned by Rocky (post #9) but it didn't work. Is there any other way?

Locate set of 5 lines in your /classes/PDF.php file with text:

 

Total products (tax incl.)

 

and remove all.

Share this post


Link to post
Share on other sites

Hi! I would like to add some words in the address displayed at the top of the invoice, as 'Phone': how can I do this?

 

thanks.

 

 

i would like to do it too... possible that everyone of you leaves data without any specification?

 

i have VAT, address and phone numbers on my PDF documents which seems honestly to be throwed on the paper without any words that explain what the VAT number is or what kind on phone number you are looking at (mobile or others?)

 

so i would like to have on the pdf something like:

 

VAT number: "VAT number coming from prestashop"

Mobile phone: "mobile phone coming from prestashop"

 

Thx

Share this post


Link to post
Share on other sites

i would like to do it too... possible that everyone of you leaves data without any specification?

 

...

 

so i would like to have on the pdf something like:

 

VAT number: "VAT number coming from prestashop"

Mobile phone: "mobile phone coming from prestashop"

 

Thx

 

It is easy to say and do badly. Ways to do this are many.

 

I'm sorry. For more complex PDF invoice editing I only choose M4 PDF Extensions module and adaptation of one of its templates. It's quick and easy.

Share this post


Link to post
Share on other sites

  • 5 months later...
  • 1 year later...
  • 1 month later...

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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More