Hi I am trying to add a custom form to woocommerce checkout. I got the form added fine. But now I need to send the field data to the woocommerce order backend with a hook.
I am using echo and get_post_meta
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 ‘
’.__(‘pickuptime’).’: ’ . get_post_meta( $order->id, ‘pickuptime’, true ) . ‘
’;}
But woocommerce is giving me an error
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, my_custom_checkout_field_display_admin_order_meta, WC_Abstract_Legacy_Order->__get, wc_doing_it_wrong Please see Debugging in WordPress for more information. (This message was added in version 3.0.) in /home/thepieho/public_html/wp-includes/functions.php on line 5225 Not sure how to edit my code