Retrieve serials onAfterOrderUpdate trigger

  • Posts: 17
  • Thank you received: 1
6 years 9 months ago #288245

-- HikaShop version -- : 3.2.2
-- Joomla version -- : 3.8.5
-- PHP version -- : 7.2.2
-- Browser(s) name and version -- : 64.0.3282.167

Hi,

I'm trying to develop an Hikashop plugin that sends the product ids and the serials attached to an external webservice whenever an order is confirmed (i'm using the onAfterOrderUpdate trigger because the onAfterConfirmOrder trigger is not called if a coupon is used to have a free product).

The issue is that in the $order object passed in the trigger, the serial data is still completely empty. It seems that the assignSerial method used by Hikaserial is called after the Hikashop plugins are called.

How can i properly retrieve the serials in an order in a Hikashop plugin (not hikaserial) with the trigger onAfterOrderUpdate ?

Thank you in advance for your response.

Last edit: 6 years 9 months ago by tcpinnovation.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
6 years 9 months ago #288249

Hi,

The trigger onAfterOrderConfirm is triggered when the customer click on the finish button at the end of the checkout. It's mainly used by payment plugins to redirect the customer to the payment gateway.

So you indeed want to use the trigger onAfterOrderUpdate in your case.
Note that in that function $order contains only the information that is being modified by the call to the save function of class.order.
So it's normal that it doesn't contain all the information of the order.
You would have to add such code to get all the data:
$orderClass= hikashop_get('class.order');
$orderInDB = $orderClass->loadFullOrder($order->order_id);
Note however that even $orderInDB should not have the data of the serials. You would have to run a MySQL query to load them yourself.
And note also that you need to configure the ordering of your plugin to be greater than the HikaShop - HikaSerial plugin in the Joomla plugins manager so that HikaSerial can add the serials to the order in the database before your plugin is triggered.

The following user(s) said Thank You: tcpinnovation

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

  • Posts: 17
  • Thank you received: 1
6 years 9 months ago #288322

Yes,

I figured before you answered that it would be the best choice to do an SQL request.

Thanks anyway !

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

Time to create page: 0.054 seconds
Powered by Kunena Forum