Create a gist now

Instantly share code, notes, and snippets.

Embed
WooCommerce - Display checkout custom field on the order edition page
/**
* Display field value on the order edition 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> ' . $order->order_custom_fields['My Field'][0] . '</p>';
}
@Simmonsstummer

This comment has been minimized.

Show comment
Hide comment
@Simmonsstummer

Simmonsstummer Feb 17, 2014

this doesn't work anymore? where is the woocommerce_admin_order_data_after_billing_address?

this doesn't work anymore? where is the woocommerce_admin_order_data_after_billing_address?

@greguly

This comment has been minimized.

Show comment
Hide comment
@greguly

greguly Feb 19, 2014

For WooCommerce 2.1, correct code for

function my_custom_checkout_field_display_admin_order_meta($order){
echo '<p><strong>'.__('My Field').':</strong> ' . $order->order_custom_fields['My Field'][0] . '</p>';
}

now becomes

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>';
}

Cheers,
Gabriel

greguly commented Feb 19, 2014

For WooCommerce 2.1, correct code for

function my_custom_checkout_field_display_admin_order_meta($order){
echo '<p><strong>'.__('My Field').':</strong> ' . $order->order_custom_fields['My Field'][0] . '</p>';
}

now becomes

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>';
}

Cheers,
Gabriel

@harisrozak

This comment has been minimized.

Show comment
Hide comment
@harisrozak

harisrozak Sep 25, 2014

@greguly thank you for the solution 👍

@greguly thank you for the solution 👍

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