onAfterOrderUpdate is not being triggered

  • Posts: 21
  • Thank you received: 0
3 years 8 months ago #322881

-- HikaShop version -- : 4.3.0
-- Joomla version -- : 3.9.19
-- PHP version -- : 7.3

Hello,

I am facing an issue in my custom payment plugin. When I my order status changes programatically then no code is being executed written in onAfterOrderUpdate method.

However I am able to trigger this from back-end but it is not working from front-end.

public function onAfterOrderUpdate(&$order) {
  if($order->old->order_status == 'created' && $order->order_status == 'cancelled') {
        echo "test"; die;
  }
}

Please let me know if I am missing anything.

Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 81484
  • Thank you received: 13062
  • MODERATOR
3 years 8 months ago #322886

Hi,

What do you mean by "When I my order status changes programatically then no code is being executed" ?
What is done to change the order status from created to cancelled on your website ? Do you open a specific URL ?
For example, if the order status is changed during a payment notification, this is usually done with a server to server connection between the payment gateway and your website directly. And thus, if there is a "echo 'test';die;" happening, it will be the server of the payment gateway which will get back a white page with the text "test", not the customer. So you, as a customer won't see anything different whether that code is executed or not.
A better way to check if and when you go into that if is to write something to a file.
That's what we usually do with payment plugins by doing something like that:
hikashop_writeToLog('test');
That hikashop_writeToLog function can be called from anywhere on your website once HikaShop's core is loaded, and it will log in the text in the "payment log file" you can see in the Files section of the HikaShop configuration page.

Last edit: 3 years 8 months ago by nicolas.

Please Log in or Create an account to join the conversation.

  • Posts: 21
  • Thank you received: 0
3 years 8 months ago #322896

Yes, I tried writing file but nothing is being executed under this function from frontend.

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
3 years 8 months ago #322900

Hello,

Can you give us more information about what do you mean by "When I my order status changes programatically then no code is being executed" ?
Also, Can you tell us what you exactly want to achieve so that we can properly advise you ? Thank you

Kind regards,
Mohamed.

Please Log in or Create an account to join the conversation.

Time to create page: 0.077 seconds
Powered by Kunena Forum