I’m trying to fetch all my WooCommerce orders where some additional metadata is equal to not empty.
$orders = wc_get_orders( array(
'orderby' => 'date',
'order' => 'DESC',
'meta_query' => array(
array(
'key' => 'var_rate',
'compare' => 'NOT EXISTS',
)
)
));
So if the var_rate
is empty or doesn’t exist then do not return that record. At the moment all orders are returned using those arguments.
Example of empty record –
object(WC_Meta_Data)#2344 (2) {
["current_data":protected]=>
array(3) {
["id"]=>
int(6471)
["key"]=>
string(15) "var_rate"
["value"]=>
NULL
}
["data":protected]=>
array(3) {
["id"]=>
int(6471)
["key"]=>
string(15) "var_rate"
["value"]=>
NULL
}
}