Skip to content
Advertisement

Add custom field data to WooCommerce order

I have a custom field on my WooCommerce single product. It sends to the cart fine, it displays on checkout fine, it shows in the order in the dashboard fine.

What I am now trying to do is set the value as a custom field in the order page so I am able to amend the text when I need to. For some reason when I submit the form this step isn’t working.

The code that i use in my functions.phpfile:

JavaScript

Screenshot of what currently happens:

Screenshot of what currently happens



What I would like to happen:

what I would like to happen


Any help would be greatly appreciated.

Advertisement

Answer

Updated: compatibility with Woocommerce version 3+

You have missing the function to display this custom field value on the order edit page:

JavaScript

On the reference link below, you have all original wooThemes functional working code snippets. It’s an excellent fully functional tutorial.

Reference: [Customizing checkout fields using actions and filters][1]


Edit: Get a custom label displayed with your custom field value in Order item meta

To get a custom label like “MY field name” with your custom field value (in order items meta) instead of a slug like my_field_name, refer to this treads:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement