Instantly share code, notes, and snippets.

Embed
What would you like to do?
[Customizing checkout fields using actions and filters] Display WooCommerce custom checkout field admin order 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){
echo '<p><strong>'.__('My Field').':</strong> ' . get_post_meta( $order->id, 'My Field', true ) . '</p>';
}
@8ozStudios

This comment has been minimized.

Show comment
Hide comment
@8ozStudios

8ozStudios Apr 2, 2018

FYI, line 7 throws an error in the admin section. $order->id should be $order->get_id().

Source: https://stackoverflow.com/questions/43231684/order-properties-should-not-be-accessed-directly-woocommerce-3-0

8ozStudios commented Apr 2, 2018

FYI, line 7 throws an error in the admin section. $order->id should be $order->get_id().

Source: https://stackoverflow.com/questions/43231684/order-properties-should-not-be-accessed-directly-woocommerce-3-0

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