Skip Navigation

[Resolved] Can you add a field with Types to the type "woocommerce order"?

This support ticket is created 4 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 6 replies, has 2 voices.

Last updated by Francisco Ramón Molina Busquiel 4 years, 11 months ago.

Assisted by: Waqar.

Author
Posts
#1406009

Hi,
I want to add information via PHP to a field that I add with types for woocommerce orders, that is, when an order is accepted and saved in the database, I can put attached information that can be displayed when viewing the woocommerce order.
Thansk for your help.
Regards,

#1406557

Hi,

Thank you for contacting us and I'd be happy to assist.

It is possible to attach custom fields from Types plugin to "Order" post type from the WooCommerce plugin.

You'll create a new custom field group with the required fields and set it to appear on the "Orders" post type.
( ref: https://toolset.com/documentation/user-guides/using-custom-fields/#how-to-add-custom-fields-to-content )

Screenshot: hidden link

After that, you'll see these fields on the post edit screen for the "Orders" posts.

Screenshot: hidden link

regards,
Waqar

#1406651

Hi Waqar!
Yes. I have done it. Thank you very much for your explanations. 🙂
Now I have 2 doubts about it:
- Can I make that field read-only?
- How can I enter a value in that field using PHP when the order is added?

I know I have to use the filter "woocommerce_new_order_item", but how do I enter the value I want in that field?

Thanks for your help.
Regards,

#1406715

Hi Waqar!
I was able to save the value in the field that I created in the orders. 🙂
So I just need to know if I can define a field as read-only, so that the user cannot modify it from the dashboard, it would be just an informational field.
Thanks for your help.
Regards,

#1407987

Thanks for the update and glad that you've managed to update the field values.

I'm not sure exactly how and where those custom fields are shown to users.

Can you please share temporary admin login details, along with the link to a page where those fields are shown?

I'll be in a better position to guide you around how to make them "read-only".

Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.

#1411419

Thank you for sharing the admin access and the screenshots.

You can make those fields read-only based on user roles, using the Toolset Access plugin, as explained in this guide:
https://toolset.com/documentation/user-guides/access-control/access-control-for-user-fields/

#1411611

It works perfectly. Thank you very much Waqar.