Jump to content

How to add custom PHP function inside invoice


bugrakorkmaz

Recommended Posts

Hi,

 

I am trying to customize invoice. I did all changes that I want but now i need some professional help.

 

I want to write, the reading of the total price, on invoice. For example if total of order on invoice is 102$, I want to write OneHundredAndTwoDollars on invoice. I have the php function for this purpose but I don' t know how to use this function inside prestashop.

 

I want to learn:

Where to put my custom php file?

How to use my custom php function inside invoice.tpl file?

 

Please guide me.

 

Thanks.

Link to comment
Share on other sites

vekia, thanks for your replay.

i don't want to use php code inside the tpl file. I want to put my php code under prestashop folders and use the return of this code inside the tpl file inside { } tags.So i want to learn where can i put my php file and how can i use the return of this code inside the tpl file.

I hope i explain clearly.

Regards.

Link to comment
Share on other sites

pdfinvoicecontroller.php

 

public function display()
{
 $order_invoice_list = $this->order->getInvoicesCollection();
 Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $order_invoice_list));
 $pdf = new PDF($order_invoice_list, PDF::TEMPLATE_INVOICE, $this->context->smarty, $this->context->language->id);
 $pdf->render();
}

Link to comment
Share on other sites

Dear Vekia,

Thanks again. But since I am new on Presta coding I really need your help.The code you sent was abit complicated for me.

My question is simple..

On invoice I would like to show some extra information but this information came from my php function. The question is;

Where can I put my php functions and show the result of this function on invoice.tpl..?

Thanks alot and sorry for bothering..

Link to comment
Share on other sites

$order_invoice_list = $this->order->getInvoicesCollection();

with code above you create a variable with invoice parameteres. As you can see - parameteres were generated in order class in the getInvoicesCollection();

 

you can add own code to this function, which will add new variables to the return (will put them to the $order_invoice_list variable)

 

then you will be able to use variables in invoice tpl file

Link to comment
Share on other sites

Thanks I will try that and let you know.

May I also ask one small question?

If a customer adds products to cart and the total cost is lets say ;

30$, then I would like to add 5 $ for extra service charge..

I mean

If the totalcost is < 30$ I will add 5$

if the totalcost is >= 30$ I will not add anything..

Is it possible to do this_? Thanks alot

Link to comment
Share on other sites

  • 1 year 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
×
×
  • Create New...