Skip to content

Instantly share code, notes, and snippets.

@mikejolley
Forked from woogist/gist:6267983
Last active January 15, 2018 19:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikejolley/9971149 to your computer and use it in GitHub Desktop.
Save mikejolley/9971149 to your computer and use it in GitHub Desktop.
WC customising checkout fields using actions and filters - Lesson 3 snippet 4
/**
* 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){
echo '<p><strong>'.__('My Field').':</strong> ' . get_post_meta( $order->id, 'My Field', true ) . '</p>';
}
@elvinlee
Copy link

Hi,

May I know how to display name instead of option_a?

@helgatheviking
Copy link

Suggestion for WC3.0+

/**
 * 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' );

function my_custom_checkout_field_display_admin_order_meta( $order ){
    echo '<p><strong>'.__( 'My Field' ).':</strong> ' . $order->get_meta( '_my_field', true, 'edit' ) . '</p>';
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment