I have this code added to functions.php and I would like the contents of my custom field to show on the orders page of WooCommerce backend.
Specifically each product that has this fields info filled in should show the special fields info to the admin user who is fulfilling the order. (each product needs its own in the area where the SKU and other data is listed)
This custom field appears on the "inventory" tab of each product in WooCommerce:
// Add Custom Field to woocommerce inventory tab for variable product
add_action( 'woocommerce_product_options_inventory_product_data', 'wc_custom_add_custom_fields' );
function wc_custom_add_custom_fields() {
// Print a custom text field
woocommerce_wp_text_input( array(
'id' => '_custom_text_field',
'label' => 'Custom Text Field',
'description' => 'This is a custom field, you can write here anything you want.',
'desc_tip' => 'true',
'placeholder' => 'Custom text'
));
}
add_action( 'woocommerce_process_product_meta', 'wc_custom_save_custom_fields' );
function wc_custom_save_custom_fields( $post_id ) {
if ( ! empty( $_POST['_custom_text_field'] ) ) {
update_post_meta( $post_id, '_custom_text_field', esc_attr( $_POST['_custom_text_field'] ) );
}
}
I don't want the user to ever see the info put in this field, only the admin users who will be completing the orders in WooCommerce orders backend section.
I have found the hook to get info into the order details section woocommerce_admin_order_data_after_order_details but I'm looking for the hook into the individual products. Any advice?