// Get current user id
$customer = get_current_user_id();
if ( !empty($customer) ) {
global $order_query;
// Get all customer orders
$order_query = new WC_Order_Query( array(
'limit' => -1,
'orderby' => 'date',
'order' => 'DESC',
'return' => 'ids',
'meta_key' => '_customer_user',
'meta_value' => get_current_user_id,
'date_query' => array(),
) );
$orders = $order_query->get_orders();
// Print to make sure all orders id's coming of respective user
print_r($orders);
$orders = $order_query->get_orders();
foreach($orders as $order_id) {
echo $order_id;
$order = new WC_Order( $order_id );
echo $order_status = $order->get_status();
$mdata = get_post_meta($order_id);
echo $delivery_date = $mdata['delivery_date_locale'][0];
echo $delivery_time = $mdata['delivery_time'][0];
echo $order_total = $mdata['_order_total'] [0];
} //closed foreach
} else {
echo 'To see orders logged to the site or create account';
}
For anyone who hopes to find valuable information on that topic, right here is the perfect blog I would highly recommend. Feel free to visit my site Article Home for additional resources about SEO.