:::: MENU ::::

WooCommerce get an order by user id

WooCommerce get an order by user id

Today we talk about WooCommerce or WordPress get an order by user id programmatically. In this tutorial, We focus on how to get user orders by using user id.

Let’s start with our example.

 $orderArg = array(
    'customer_id' => 23,
    'limit' => -1,
    'orderby' => 'date',
        'order' => 'DESC',
    );
$orders = wc_get_orders($orderArg);
if($orders){
  foreach ($orders as  $orderData) {
                print_r($orderData);
         }
}
Author: Qaisar Satti
Last Modified: July 14, 2021


Comments are closed.