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,
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
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,
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,
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.
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/
It works perfectly. Thank you very much Waqar.