onAfterOrderUpdate in my plugin is no longer called after end checkout.

  • Posts: 11
  • Thank you received: 1
  • Hikashop Business
5 days 17 hours ago #366399

-- HikaShop version -- : 5.1.2
-- Joomla version -- : 5
-- PHP version -- : 8
-- Browser(s) name and version -- : Chrome

Hi,
onAfterOrderUpdate in my plugin is no longer called after end checkout.
I need that to do some update in my database and control differents thank you message.
I tried with a coupon and width CB paiement.
It triggered before i did my last hikashop update
It is possible that something changed ?
Oh, i have to say some other functions of my plugin has well called as onAfterOrderCreate etc ...
Thank you
Bob

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

  • Posts: 11
  • Thank you received: 1
  • Hikashop Business
5 days 17 hours ago #366400

I forgot to specify, at the end of checkout i fall on this page https... /checkout/confirm with "thank you for your order etc ..."

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

  • Posts: 83541
  • Thank you received: 13516
  • MODERATOR
5 days 13 hours ago #366401

Hi,

I'll first explain the steps at the end of a checkout:

When the use clicks on the "finish" button, at the end of the checkout, HikaShop triggers onBeforeOrderCreate, creates the order, triggers onAfterOrderCreate and then triggers the onAfterOrderConfirm of the payment plugin of the selected payment method.

Usually, at that point, the payment plugin redirects the customer to the payment form of the payment gateway and the customer pays. Then, after the payment gateway knows the payment is successful, it will usually contact the payment plugin via onPaymentNotification in a server to server communication. In that onPaymentNotification, the payment plugin will request HikaShop to change the order status of the order from "created" to "confirmed", which will trigger the onBeforeOrderUpdate and onAfterOrderUpdate.
In parrallel, or after the server to server communication, the payment gateway will redirect the customer to the thank you page.
This process has always been the same regardless of the version or edition of HikaShop.

Now, there are 2 main variations to these steps:

- If the total amount of the order is zero, onAfterOrderConfirm is not called and the thank you page is directly displayed by HikaShop. Also, HikaShop has a plugin "free order validation" which can change the status of these zero total amount orders to "confirmed", either with trigger to onAfterOrderUpdate or without, based on its settings.

- If the customer selects an offline payment method, like "bank transfer" or "collect on delivery", in onAfterOrderConfirm, the corresponding payment plugin will directly display a custom thank you page with information about use to make the payment. The payment method has a setting to force the order status to be changed (that way, you can have it changed to a "pending" status for these offline payment methods), and in that case, trigger onAfterOrderUpdate. Also, no server to server communication will take place after the payment, so you would have to manually change the status of the order to "confirmed" after the payment is received.

Knowing all of that, when you say "after end checkout" I'm not clear on what you mean, supposing that we're talking about the general case of a payment plugin with the payment going through a payment gateway.
Do you mean "after the user clicks on the finish" button ?
In that case, it's normal that onAfterOrderUpdate is not called at the time. It should only happen in special cases ( with a zero total amount order and the free order validation plugin configured to change the status, or with an offline payment method configured to change the status ).
Or do you mean "on the thank you page" ?
In that case, it's also normal since the onAfterOrderUpdate happens in the server to server communication, which the user is not part of.

Also, it is totally possible that by the time the customer is redirected to the thank you page, the server to server communication for the payment notification has not yet taken place. It depends on how the payment gateway works. Usually, the payment gateway will wait for the server to server communication to finish before redirecting the customer, but some might not.

Sorry for the lengthy answer, but I can't tell you what the problem is as I don't have the code of your plugin on my end, so I figured it is best to tell you how the system works so that you can make sure your mental model matches with the reality of the processes, which will probably help you understand what is wrong in the assumptions you made when developing the plugin.

Last edit: 5 days 16 hours ago by nicolas.

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

  • Posts: 11
  • Thank you received: 1
  • Hikashop Business
5 days 11 hours ago #366406

First of all, thank you for these helpful explanations.
The bank payment has been down for a few days, so you're testing it completely. I'm using a coupon that covers the entire cart so I don't have to pay for tests.
So I'm not going through the payment process. Two weeks ago, my coupon tests worked and called the plugin method all at once; this is no longer the case.

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

  • Posts: 83541
  • Thank you received: 13516
  • MODERATOR
5 days 8 hours ago #366410

Hi,

If you're using a coupon code, to get a 100% discount on the order to get a total at 0, then, by default the order is created and the thank you page is displayed, and nothing else happens. It's normal that in this case, the onAfterOrderUpdate event is not triggered.
For it to be triggered, you need to enable the "Hikashop Validate free order Plugin" and configure it to activate its "Send confirmation email" setting.
That's the first variation I was talking about in my previous message.
So, in your case, the first thing to check is the Hikashop Validate free order Plugin via the Joomla plugins manager.

Last edit: 5 days 8 hours ago by nicolas.

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

  • Posts: 11
  • Thank you received: 1
  • Hikashop Business
5 days 8 hours ago #366413

Thank you, it works like a charm; that's what I had disabled.
I congratulate you on your speed and professionalism.

The following user(s) said Thank You: nicolas

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

Time to create page: 0.062 seconds
Powered by Kunena Forum