Add custom field data to WooCommerce order Add custom field data to WooCommerce order wordpress wordpress

Add custom field data to WooCommerce order


Updated: compatibility with Woocommerce version 3+

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

/** * Display field value on the order edit page */add_action( 'woocommerce_admin_order_data_after_billing_address', 'my_custom_checkout_field_display_admin_order_meta', 10, 1 );function my_custom_checkout_field_display_admin_order_meta( $order ){    $order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id;    echo '<p><strong>'.__('My Field Name').':</strong> ' . get_post_meta( $order_id, 'my_field_name', true ) . '</p>';}

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: