Jump to content

Trigger function when invoice is created


hypnootik

Recommended Posts

Hi

I am trying to build a module that creates xml file from invoice every time invoice is created.
So far the best I came up with is this function in my module.
 


public function hookActionPaymentConfirmation ($params) {
$this->hookActionOrderStatusUpdate($params);
}
 
public function hookActionOrderStatusUpdate($params) {
$order = new Order((int)$params['id_order']);

And it executes my module when I change the order status to "payment accepted". Unfortunately I do not get any invoice data ($params) on the first time order status is updated to "payment accepted". I do get the invoice data eventually but only when I chanee order status for the second time.
 

Order Object (
......
[invoice_number] => 0

 
I presume this hook is called before invoice is actually generated and therefore I get nothing from $params and are unable to generate xml.

What is the correct way to trigger function and get the invoice data?

Edited by hypnootik (see edit history)
Link to comment
Share on other sites

Found the solution for my problem.

I was using wrong Hook.
The correct hook is 

actionOrderStatusPostUpdate

instead of 

actionOrderStatusUpdate

It is so unfortunate that all this information is lacking from PS official documentation.
Would have been so easy, but instead I had to google my way out of this :)

  • Like 1
Link to comment
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
×
×
  • Create New...