- Posts: 45
- Thank you received: 0
How to modify custom fields with a plug-in
- paulvanharen
-
Topic Author
- Offline
Less
More
8 years 7 months ago #287716
by paulvanharen
How to modify custom fields with a plug-in was created by paulvanharen
-- HikaShop version -- : 3.2.2
-- Joomla version -- : 3.8.5
-- PHP version -- : 7.1
I've created some custom fields for the table "order", and a skeleton plug-in in plugins/hikashop. When the plugin is triggered by the onAfterOrderCreate event, I'd like to log some data in my newly created fields. I would expect the fields to be found in the order object, but alas!
Where can I access these order fields?
Thanks and regards, Paul
-- Joomla version -- : 3.8.5
-- PHP version -- : 7.1
I've created some custom fields for the table "order", and a skeleton plug-in in plugins/hikashop. When the plugin is triggered by the onAfterOrderCreate event, I'd like to log some data in my newly created fields. I would expect the fields to be found in the order object, but alas!
Where can I access these order fields?
Thanks and regards, Paul
Please Log in or Create an account to join the conversation.
8 years 7 months ago #287719
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 modify custom fields with a plug-in
Hello,
Order custom fields are in the order object ; if the object contains data to modify the field content.
But it's possible that a save do not contains the fields because it don't want to change the value.
It does not mean that you can't put some data into.
Regards,
Order custom fields are in the order object ; if the object contains data to modify the field content.
But it's possible that a save do not contains the fields because it don't want to change the value.
It does not mean that you can't put some data into.
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.
- paulvanharen
-
Topic Author
- Offline
Less
More
- Posts: 45
- Thank you received: 0
8 years 7 months ago #287769
by paulvanharen
Replied by paulvanharen on topic How to modify custom fields with a plug-in
Hi Jerome,
Do I understand correctly that the field is not available in case no value is set yet?
That would explain a lot.
Regards, Paul
Do I understand correctly that the field is not available in case no value is set yet?
That would explain a lot.
Regards, Paul
Please Log in or Create an account to join the conversation.
8 years 7 months ago #287772
by nicolas
Replied by nicolas on topic How to modify custom fields with a plug-in
Hi,
Yes, In the $order object you get in onAfterOrderCreate , you only have the custom order fields that are being saved with the order creation. If your custom order field is not in the checkout, then it won't be in $order in that trigger.
But as Jerome said, you can run a MySQL query to set it.
Or you can even use the onBeforeOrderCreate trigger to set it in $order and it will be saved for you when the order is created in the database.
Yes, In the $order object you get in onAfterOrderCreate , you only have the custom order fields that are being saved with the order creation. If your custom order field is not in the checkout, then it won't be in $order in that trigger.
But as Jerome said, you can run a MySQL query to set it.
Or you can even use the onBeforeOrderCreate trigger to set it in $order and it will be saved for you when the order is created in the database.
The following user(s) said Thank You: paulvanharen
Please Log in or Create an account to join the conversation.
Time to create page: 0.255 seconds