Add appointment date to WooCommerce orders tab (frontend)

107 views Asked by At

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

1

There are 1 answers

5
mujuonly On
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);
    }
}