Display custom checkout field value in Woocommerce Bookings metadata

98 views Asked by At

Based on this description, I made a custom dropdown field to the WooCommerce Checkout Page.

I would like to see this value among the metadata in Woocommerce Bookings plugin. Bookings: Action and Filter reference

add_action( 'woocommerce_admin_booking_data_after_booking_details', 'wps_select_checkout_field_display_booking_order_meta');
function wps_select_checkout_field_display_booking_order_meta($order){
    echo '<p><strong>'.__('Communication').':</strong> ' . get_post_meta( $order->id, 'comm_plat', true ) . '</p>';

}

But I only see the 'Communication:' text, without the value. Can anyone help me with this?

1

There are 1 answers

4
Wisdom Ighofose On

Taking a look at your echo statement the following are possible reasons you are not seeing the value:

1: 'comm_plat' is not save to post_meta as such it is returning empty string

2: 'comm_plat' might be wrongly spelled when saving the value which means you are querying with a wrong name

3: On the link you provided there is no hook with the name woocommerce_admin_booking_data_after_booking_details the closest to that was woocommerce_admin_order_data_after_billing_address

4: Is the $order parameter passed to the hooked (you can know this by printing out the $order variable like so:

add_action( 'woocommerce_admin_booking_data_after_booking_details', 'wps_select_checkout_field_display_booking_order_meta');
function wps_select_checkout_field_display_booking_order_meta($order){
  print_r($order)
}