'Add appointment date to WooCommerce orders tab (frontend)
I am using JetAppoitment (crocoblock) to make services bookable. I would like to add the appoitment date to the orders from the front-end side.
Here is the code I used :
add_filter( 'woocommerce_account_orders_columns', 'add_account_orders_column', 10, 1 );
function add_account_orders_column( $columns ){
$columns['custom-column'] = __( 'Date de livraison', 'woocommerce' );
return $columns;
}
add_action( 'woocommerce_my_account_my_orders_column_custom-column',
'add_account_orders_column_rows' );
function add_account_orders_column_rows( $order ) {
// Example with a custom field
if ( $value = $order->get_meta( '_appointment_date' ) ) {
echo esc_html( $value );
}
}
The first part of the code worked good, the extra column is here : https://i.stack.imgur.com/kSLiq.png
The problem is I have no data...
Any idea to how to fix it?
Thanks
Solution 1:[1]
add_action('woocommerce_my_account_my_orders_column_custom-column',
'add_account_orders_column_rows');
function add_account_orders_column_rows($order) {
// Example with a custom field
if ($value = get_post_meta($order->get_id(), '_appointment_date')) {
echo esc_html($value);
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | mujuonly |
