How to get HikaSerial number in a custom plugin

  • Posts: 17
  • Thank you received: 0
  • Hikaserial Standard Hikashop Business
1 week 6 days ago #361973

-- HikaShop version -- : 5.1.0
-- Joomla version -- : 4.4.5
-- PHP version -- : 8.2.20-nmm1

We create a custom plugin for the HikaShop. The plugin uses the onAfterOrderUpdate to take the placed order and forward the data to a CRM system. Some products have a HikaSerial randomgen package asigned. In the custom plugin I need to get the generated serialnumbers. Is there a direct way to get these numbers from the $order object? If not, is there a other smooth way or do I have to access the db directly?

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

  • Posts: 26072
  • Thank you received: 4015
  • MODERATOR
1 week 5 days ago #362026

Hello,

You will find details under :

$order->order_serials
But you need to be sure that your plugin is called after the plugin "hikashop / serial".
Because the serial creation is also done during the "onAfterOrderUpdate" trigger, so that variable is filled at that moment.
If your plugin is called before, you won't be able to access the data ; when serials are created/assigned.
If the serials are already there (and the order status doesn't change), you will have to load the serials from the database. Loading the serials every time an HikaShop order is loaded would have some performance impacts.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 17
  • Thank you received: 0
  • Hikaserial Standard Hikashop Business
1 week 4 days ago #362052

Obviously my plugin come first. The $order->order_serials is empty

    [order_serials] => stdClass Object
        (
            [packs] => Array
                (
                )

            [serials] => Array
                (
                )
How can I tell my plugin to wait for the hikashop serial plugin?
For the moment I do a database query which works but if I understood it right I have the risk of a race condition...

Regards
Richard

Last edit: 1 week 4 days ago by Jerome. Reason: adding [code] tag

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

  • Posts: 26072
  • Thank you received: 4015
  • MODERATOR
1 week 4 days ago #362059

Hello,

If you have the variable, then you're after HikaSerial.
But the trigger call doesn't apply that serial will be assigned or unassigned to the order ; thus the best for you would to be load the HikaSerial "order" class and call the function : loadSerialData($order_id)
It will perform the loading in the database and return it.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

Time to create page: 0.060 seconds
Powered by Kunena Forum