How to modify custom fields with a plug-in

  • Posts: 44
  • Thank you received: 0
  • Hikashop Business
6 months 1 week ago #287716

-- 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.

  • Posts: 22679
  • Thank you received: 3522
  • MODERATOR
6 months 1 week ago #287719

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.

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: 44
  • Thank you received: 0
  • Hikashop Business
6 months 1 week ago #287769

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.

  • Posts: 63029
  • Thank you received: 9058
  • MODERATOR
6 months 1 week ago #287772

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.076 seconds
Powered by Kunena Forum