I need to get all my orders from WooCommerce where some extra metadata is equal to not zero.
$orders = wc_get_orders( array(
'orderby' => 'date',
'order' => 'DESC',
'meta_query' => array(
array(
'key' => 'var_rate',
'compare' => 'NOT EXISTS',
)
)
));
Whenvar_rate
is empty or doesn't exist then it will not return that record. Presently all orders are returned using those arguments.
See the 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
}
}