I'm trying to get all the shop orders with a meta key "order_referrer_id" and the value will be a user id for example "1060".
This is what i have tried so far:
$args = array(
'limit' => -1,
'status' => 'completed',
'meta_query' => array(
array(
'key' => 'order_referrer_id',
'value' => 1060,
'compare' => '='
),
),
'return' => 'ids',
);
$orders = wc_get_orders( $args );
For some reason the query ignore the meta query and returns all the orders.
What is the correct way to filter shop orders?
wc_get_orders
does not take all the same arguments, as f.e.get_posts
would. You will have to do it this way, github.com/woocommerce/woocommerce/wiki/… – Recalcitrant