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
- Where exactly do I write define( ‘WP_DEBUG’, true ) in wp-config file
- Dynamically Override Fancy Title – Part II
- error_log is not working as expected in functions.php file
- Replace existing content from specific WooCommerce admin orders list column
- mysqli_real_connect() – authentication method unknown to the client Warnings
- How to debug php code in hostgator cPanel
- How to get woocommerce cart content without an action?
- WooCommerce: Add Payment Gateway Field to Webhooks [closed]
- Use wp_get_recent_posts with search term
- Woocommerce product download URL
- Multiple choice in a custom taxonomy
- Limiting woocommerce line_total decimal length
- Remove price from Woocommerce variable product dropdown menu
- Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)
- WordPress 3.2 query_posts and pagination, permalinks issue
- only show container with next/prev links if they exist?
- Get and insert order email address to the PHP template inside HTML text
- If no products are on sale – hide ID or class
- How to store post ID’s in cookie or session to display the same posts later
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- register_taxonomy() take much queries
- Get posts from multiple post type
- Replace Woocommerce “add to cart” to be “Download” button [closed]
- the_posts_pagination() not working in wpquery
- Issue with custom loop in Archive page
- customize woocommerce templates and display store on home
- WC_Customer delete function returns error
- Increment paged on WP_Query
- Hide posts if user is added to it WP_query
- Woocommerce: remove total sum from new order’s email [closed]
- Order BY Most Liked And Published Between Previous Week Monday And Next Week Monday
- custom post type with role Vendor
- WooCommerce: Display product categories to make IF statement
- Modifying WP URL handing code?
- Free search and custom taxonomy query not providing the same result
- How do I reset $wp_query in a function?
- Modify WooCommerce used to get all orders in dashboard
- Advanced Query posts
- Add Custom Category Description When Empty
- Replace a single variable with add_filter
- I am having issue in divi woocomerce checkout module. (DIVI theme)
- How can I check that the acf field value is not a duplicate when adding a post?
- Add a product category to a specific product via a button
- Display div if category has a specific parent
- meta_query search names when they have middle initials
- global $product is empty string when passed into function
- How to identify which php file a plugin is using on page load?
- Need to forward Data from WooCommerce Webhook sent to same site WordPress REST API custom endpoint
- Add Product Permalink in woocommerce admin order page
- List all ACF field values across every post on one page
- Query to show average # of months all accounts with specific role have been active
- WooCommerce Custom Tab with ACF Repeater Field
- How to make a parent page for author.php?
- Querying posts from wordpress with 2 or more conditionals
- Display Year and Month from custom field + Age Calculator
- How to find the function which is outputting Array
- Getting custom field data from cart page to checkout page in woocomerce [closed]
- which php or css file has generated an inline style in WordPress that overwrites my css
- Show button in header when product custom field is not empty
- WordPress 6.1.1 UTF8 Slug Limit Increase
- How to add SKU and remove product title from WooCommerce url?
- Product Search in search.php
- using custom pages for myaccount in woocommerce