I like to use
wc_get_orders() function to get WooCommerce orders in front end.
Here is my code snippet to get orders.
$args = array( 'customer_id' => get_current_user_id(), 'return' => 'ids', ); $customer_orders = wc_get_orders( $args ); var_dump($customer_orders);
The above code will return all orders of current users.
The issue is, the wc_get_orders return all orders including trashed orders. Is there any option to exclude trashed orders?
More details about this function are available in this link.