I used a function to add a custom field to order meta with the action woocommerce_checkout_update_order_meta
. I can see the custom fields on the admin page, but I cannot make those custom fields appeared in the order page of the website.
Here is the code:
add_action( 'woocommerce_checkout_update_order_meta', 'time_field_update_order_meta' );
function time_field_update_order_meta( $order_id ) {
if ( $_POST['time_1'] ) {
update_post_meta( $order_id, 'Time 1', sanitize_text_field( $_POST['time_1'] ) );
}
if ( $_POST['time_2'] ) {
update_post_meta( $order_id, 'Time 2', sanitize_text_field( $_POST['time_2'] ) );
}
}
Is there another action or filter that I can add on my functions.php
to display those custom fields too?
You could try using a similar function like the one shown here on github: https://gist.github.com/woogist/6267983