Skip to main content

How to modify custom fields with a plug-in

More
8 years 8 months ago #287716 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

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

More
8 years 8 months ago #287719 by Jerome
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,

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

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

More
8 years 8 months ago #287769 by paulvanharen
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

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

More
8 years 8 months ago #287772 by nicolas
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.
The following user(s) said Thank You: paulvanharen

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

Time to create page: 0.152 seconds
Powered by Kunena Forum