The meta_query
argument (that you can use in a WP_Query
) is not enabled by default when using a WC_Order_Query
through wc_get_orders()
WooCommerce function.
But for you can use the undocumented Custom Field Parameters (just like in a WP_Query
):
meta_key
meta_value
meta_value_num
meta_compare
So in your case you can use the following instead:
$orders = wc_get_orders( array(
'limit' => -1, // Query all orders
'orderby' => 'date',
'order' => 'DESC',
'meta_key' => 'var_rate', // The postmeta key field
'meta_compare' => 'NOT EXISTS', // The comparison argument
));
This time it works nicely (Tested on WooCommerce 3.5.8 and 3.6.2).
Related Posts:
- Woocommerce Get Orders By Meta Value
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- Custom WP_Query order by post_meta and (author) user_meta
- WP_Query for WooCommerce Products
- Perform query with meta_value date
- Finding all results from database within 500 miles of the given latitude and longitude [closed]
- WooCommerce: filter by parent product’s taxonomy and product variation’s meta data
- how to retrieve specific product attribute value in an sql query?
- WP Query – Get WooCommerce Products with variation that is in stock
- Meta Query for specific months
- How to orderby meta_value_num with dollar ($) sign
- Extending woocommerce admin product search
- merge two query arguments into one WP_Query call
- Get all products which have both product category
- Optional Meta Query
- Overwrite YoastSEO meta-tags with another page’s [closed]
- How to orderby multiple meta fields if some fields are empty
- Extend product search with meta in WooCommerce
- Meta Query relation “AND” then set array accordingly
- How to set up hierarchical relationships without using plugins / meta query
- Multiple meta_key ordering with pre_get_posts
- Is it possible to retrieve posts depending on meta_key LIKE condition? [duplicate]
- Why doesn’t my WP Meta Query return any results?
- WP_Query meta compare must include ALL array values
- meta_query where the meta value is not the post title
- Query multiple post types, but different order for each
- ElasticPress is (aparently) messing with my search filters
- How to do WP_User_Query for Nested Array value Inside Nested Array field
- Meta query orderby meta_value_num sorting by role first
- Query against multiple locations within single custom post type post
- Strange results from WP_Query
- WP Query. Ordering posts by another post types meta
- Slow wp_posts and wp_postmeta query using Advance Custom Fields
- Query by meta value (add a dropdown of all values)
- Meta query doesn’t remove placeholder escape before query
- Create global array to compare inside a query
- What is the best way to reset a search on a meta_key / meta_value?
- How can I modify standard search query to include also ACF custom fields values?
- Using the same WP_Query for shop and widgets in WooCommerce shop
- Filter posts/pages by user_role array
- Woocommerce set loop_shop_columns to be 3 in the main shop page loop only and 4 otherwise
- Use meta query only 3 or more results?
- Use value from meta key array for use in WP_Query
- Make a WP Query search match exactly the search term
- pre_get_posts with get_posts
- Query Custom Meta Value with Increment
- Changing a theme’s search function to only show results from woocommerce?
- querying with custom meta field with meta_query
- Order by two meta keys
- multiple meta key but get server load is very high
- A WP_Query that will look for posts after 2 weeks ago OR with a certain meta value
- Finding the next 5 posts
- Pass the same object to multiple widgets in a template with one query
- Use meta_query to display events by date in custom field
- What is considered a default query for the request filter?
- $wpdb insert is not work
- Using WP_Query and WP_Meta_Query Outside of WordPress
- How to find exact match for search term in WP_Query? What is the additional string added in LIKE query in WP_Query?
- If two first numbers exist in wp_meta_query value
- How to get the WC_Product Object when using a WP_Query in WooCommerce
- How to query a custom post type with a taxonomy filter but display post type archive page?
- Tax query clause inside a meta query clause?
- Change query_posts to WP_Query in page but does not work
- WP Query with custom Shortcode
- Set conditional on template based on referring page slug
- How do I make a meta_query OR relation work? [closed]
- Meta_query on same meta key, with diffrenct values
- Can we return all category (not post) with Custom Query Filter? [closed]
- Filter posts in category archive page by year using a dropdown
- Woocommerce – Changing the order of the upsell products [closed]
- WP_Query with meta_query dosen’t return results
- date_query seems to be ignored by wp_query
- WooCommerce search products between price range using WP_Query
- Better wordpress attachment query than this
- Is it possible to query from external database? [duplicate]
- Can’t sort custom post type by random
- WP_Query for products always returns empty
- Show single posts date, in a page of posts
- Order WP_Query by meta_key priority when ‘OR’ relation used for multiple meta values
- Multi-layered WP_Query
- `offset` WP_Query argument dont work via `pre_get_posts`
- Pagination of custom page with custom fields query
- Save large WP_Query to transient === false
- meta_query is overriding default search
- Custom Woocommerce Product Query
- WP_User_Query Orderby Not Working
- Unusual high query of user meta data
- Woocommerce featured products query no longer working
- WordPress Query optimaization for slow query
- Query custom meta value – post view and date meta
- Custom WP_query and integrating into theme file
- WP_Query – show posts where meta value and user_email match
- WP_Query using meta_query with LIKE doesn’t return what it should
- How to get query results for the next page
- How to organize a WP_Query’s list of posts by category and display category title?
- Need help setting up a search form for wordpress [duplicate]
- Including ‘cat’ => $cat breaks meta_query
- Query string form $_GET[‘value’] is not working as meta value in wp_query
- Filtering product search results using tags
- WP Query returning all posts when Meta_query is null