- Posts: 28
- Thank you received: 0
How to get HikaSerial number in a custom plugin
2 years 2 months ago #361973
by RitchieM
How to get HikaSerial number in a custom plugin was created by RitchieM
-- 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?
-- 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.
2 years 2 months ago #362026
by Jerome
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.
Replied by Jerome on topic How to get HikaSerial number in a custom plugin
Hello,
You will find details under :
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,
You will find details under :
Code:
$order->order_serials
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.
2 years 2 months ago - 2 years 2 months ago #362052
by RitchieM
Replied by RitchieM on topic How to get HikaSerial number in a custom plugin
Obviously my plugin come first. The $order->order_serials is empty
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
Code:
[order_serials] => stdClass Object
(
[packs] => Array
(
)
[serials] => Array
(
)
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: 2 years 2 months ago by Jerome. Reason: adding [code] tag
Please Log in or Create an account to join the conversation.
2 years 2 months ago #362059
by Jerome
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.
Replied by Jerome on topic How to get HikaSerial number in a custom plugin
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,
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.215 seconds