WC_Order_Query
does not store a record of the SQL it generated, or the WP_Query
that it used internally. So it’s not possible to get the information you need from WC_Order_Query
directly.
You could try using $wpdb->last_query
immediately after using the class or function, but the last query more than likely isn’t the one you’re actually looking for:
global $wpdb;
$orders = wc_get_orders();
$query = $wpdb->last_query;
Your best bet is to use a tool like Query Monitor, which will allow you to see all the SQL queries run during a page load. You could use this to inspect your query.
Related Posts:
- Display related products with custom output
- Query multiple custom post types in single loop
- retrieve thumbnail from post ID of best selling product in category
- How to create a WP_Query to search the Title or Tag?
- WP_Query | Help me create a search term with an ‘OR’ relation?
- Using Cookie Data For WP_Query Loop
- How to get to a specific position in wp_query?
- Why is variable not working on custom sql query using wpdb?
- How can I use wp_query to show all product data using just the products ID?
- Get stock by custom meta field on all Woocommerce variable products
- Create WP_Query to search for posts by their categories or their parent/child categories
- WP Query with custom Shortcode
- Display a specific category of products in shop page and disable code for specific actions
- WordPress default Search function inconsistent in WooCommerce Product Titles
- unable to use ‘new WP_Query’ in AJAX call
- How to add div blocks after certain set of post
- How to overwrite orderby with add_query_var
- How to hide posts of a specific custom category in WordPress?
- WP_Query multiple post results
- WordPress WP_Query without query GET parameters
- How can I modify this code to make the search box include tags and meta
- Output product category link from WP_Query
- How to work Woocommerce pagination inside shortcode?
- WP_Query for woocommerce products with a pattern as a post_title
- get_filtered_term_product_counts – Get product terms if any products
- WP_Query To Display Product Of Brand On Taxonomy Page
- wordpress query returning unexpected results
- Woocommerce Related Product by 2 taxonomy
- Query doesn’t display text data with apostrophes
- wp_query beginner
- How can I display a query in a page?
- WooCommerce – Print Processing orders [closed]
- Does wp_query and query_posts affect website performance? [duplicate]
- Ajax Load More or View More functionality for woocommerce category layout by template overriding
- wp_query on search results page showing all results every time
- Show post like this image in my newssite [closed]
- Three different queries on same page
- Get all posts as an array ID => Name
- PHP -> SQL Query with Summing
- woocommerce related product title length
- Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
- How to insert wp_users ->user login name to wp_terms when a new user registering?
- woocommerce wc_create_order(); is creating multiple orders instead of one?
- Create a package of products as one Item in woocommerce?
- Post not populating for custom post type based on category selection
- Passing an array into WP_Query as a variable
- Woocommerce: remove total sum from new order’s email [closed]
- Custom query vars filters problem with pagination
- Custom post type permalinks do not appear using the link functions
- Include js script ONLY on woocommerce product category pages? [closed]
- WordPress meta_query >= &
- extract serialized array to use for wp-query
- Order BY Most Liked And Published Between Previous Week Monday And Next Week Monday
- Hooks for post saving make a post-new.php to load latest post’s data
- Convert Featured products loop into Recent products loop?
- fetch woocommerce product with custom taxonomy
- Modify main query before it run without pre_get_post
- Where to copy woocommerce files to in my custom theme to avoid editing the core plugin?
- Sort posts in a specific way
- Alter Woocommerce product archive structure
- Do not duplicate posts with multiple categories in multiple loops
- Have Woocommerce show product price if id, when not logged in
- Infinite Loop – WP_Query
- How can I split my query result in 2 arrays?
- After disabling WPML multi currency, the currency is still handled by the WPML
- custom post type with role Vendor
- How do i wrap woocomerce attribute in list?
- Removing files programmatically
- array_rand not working correctly?
- WooCommerce: Display product categories to make IF statement
- WordPress site with embedded menu – gives You don’t have permission to access /wp-content/themes/xxx/taxonomy-redirect.php on this server
- Dividing the loop to style post differently
- add button to specific post
- WordPress PHP syntax doesn’t seem to be working correctly
- WP_Query() load selected post
- echo var into wp_query
- How to get post category list as select in front-end?
- Querying for specific tags
- Order a WP_Query by meta value where the value is an array
- Woocommerce custom Plugin in wordpress [closed]
- How to get thumbnail with pure PHP in a WordPress database?
- Limit tags shown in post
- WooCommerce “Checkout Now” button [closed]
- How do I check if there is a tag in the title
- Why my query does not run with prepare
- Custom Taxonomy Select Menu: Setting default option value?
- How to extract information from a wp_query result?
- mySQL queries are executed twice on wordpress website
- posts_nav_link pulling in multiple post types
- Displaying Event within two given time frames
- List of Events with Multiple Dates: Only NEXT Date
- Echo array value
- Remove Post if Advanced Custom Field is checked to fix paging
- Undefined variable: row?
- Toolbar Hidden in a Virtual Page
- displaying a fall back query if there’s nothing in the post-type category
- WordPress SQL JOIN query
- Using multiple variables to assign categories to an array
- Search.php gets metadata from first post
- Change Query Arguments (filter) with jQuery/Ajax or PHP?