You can fetch all WooCommerce orders of a single customer by different parameter.
Here you can find all WooCommerce orders of a customer by user id.
Use the following to fetch all orders of a single customer in WooCommerce by user ID.
You have to replace customer id instead of ‘CUSTOMER_USER_ID_HERE’.

$user_id='CUSTOMER_USER_ID_HERE';
$customer_orders = get_posts( array(
                    'meta_key'    => '_customer_user',
                    'meta_value'  => $user_id,
                    'post_type'   => 'shop_order',
                    'post_status' => array_keys( wc_get_order_statuses() ),
                    'numberposts' => -1
                ));

Have any doubt, then comment here!

1 Comment on Get all orders of a single customer in WooCommerce by user ID

Leave a Reply

Your email address will not be published. Required fields are marked *