Skip to content

Instantly share code, notes, and snippets.

@emarket-design
Last active April 1, 2016 17:23
Show Gist options
  • Save emarket-design/7bba876a0f2988832d333956f45a572f to your computer and use it in GitHub Desktop.
Save emarket-design/7bba876a0f2988832d333956f45a572f to your computer and use it in GitHub Desktop.
How to get all order ids of a customer in WooCommerce
if(is_user_logged_in()){
$cust_orders = get_posts( array(
'numberposts' => -1,
'meta_key' => '_customer_user',
'meta_value' => get_current_user_id(),
'fields' => 'ids',
'post_type' => wc_get_order_types(),
'post_status' => array_keys( wc_get_order_statuses() ),
'orderby' => 'date',
'order' => 'DESC'
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment