Created
March 11, 2018 15:17
-
-
Save woogists/fba058890c3a49f649fc6fe8eb9ddf7c to your computer and use it in GitHub Desktop.
[Customizing checkout fields using actions and filters] Display WooCommerce custom checkout field admin order page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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>'; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes that is the case, full error message is: "Notice: id was called incorrectly. Order properties should not be accessed directly. Backtrace: require('wp-admin/edit-form-advanced.php'), do_meta_boxes, WC_Meta_Box_Order_Data::output, do_action('woocommerce_admin_order_data_after_billing_address'), WP_Hook->do_action, WP_Hook->apply_filters, wpdesk_vat_number_display_admin_order_meta, WC_Abstract_Legacy_Order->__get, wc_doing_it_wrong Please see Debugging in Website for more information. (This message was added in version 3.0.) in ****/wp-includes/functions.php on line 5313"
Found a nice solution here https://stackoverflow.com/questions/65359251/display-custom-meta-data-in-woocommerce-admin-order-after-billing-address