You’ll find details here: https://gist.github.com/lukecav/05afef12feaf980c121da9afb9291ad5
OR
Another approach is https://github.com/woocommerce/woocommerce/wiki/wc_get_orders-and-WC_Order_Query . Use if….else and store order data in Arr[product_id] = OrderArr
Kindly accept my answer if it is of any help.
Related Posts:
- wpdb custom post_type problem
- Combine tax_query and meta_query in WP_Query
- Query for posts from any post type but only add instock products
- Want to filter only parent post in admin area
- Woocommerce query specific product from specific category
- Calculating Bayesian average for custom post type
- $wpdb: Counting posts corresponding to 3 terms in 3 different taxonomies
- Insert post metadata for all posts in CPT at once if metadata no existent
- Convert simple SQL Query to WordPress query
- convert custom query to wp_query
- Converting the_content string to an array?
- Woocommerce search pagination not working
- Proper way to display latest 5 posts grouped by post type?
- Sort posts in loop by the WooCommerce Membership of the author
- WPDB for post count on post
- Get all post from a post type
- foreach loop inside the loop creating duplicates in output
- $wpdb is queried but results don’t show
- How to use costum database table for custom post type
- Custom post order when using OR relation
- CPT or Custom Table for Repository of Serial Numbers
- Assign a tag to custom post type using a query
- Pre defined checkbox / radio button state based on value stored in ACF fields in checkout form WooCommerce
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- Query all post and CPT from 2 specific taxonomies AND by ACF custom field
- Pagination not working on custom query on a page
- Query within a foreach within a query (queryception)
- Cannot get custom post
- find custom post type post by searching its custom field with my string
- wordpress lists similar type of posts in a custom post type
- FacetWP paging custom wp_query
- Update post if exist from PHP
- Different options per post type in WP_Query
- Custom post type and standard post not displaying or working
- Empty search input does not return all posts
- How to properly rewrite pagination rules for a CPT to avoid 404 error on /page/2
- $post->post_meta not pulling any post in wordpress/php
- Get decimal from product price with Mysql
- Show message when query has no posts
- How to sort a WP_Query by a custom field AND ALSO filter by a different custom field
- WP_Query of custom post type sorted by meta_key has unexpected results
- How to show all taxonomies within custom post type loop
- Undefined $post in wp_query
- Returning a custom content types with meta values
- Adding Multiple Post Types to Query [duplicate]
- WP_Query not resetting after wp_reset_postdata
- How to get the post terms from a child taxonomy
- Custom Category Walker with Image, Fallback to Most Recent Post in Category Image
- display posts of custom post type with custom taxonomy
- WP_Query order by two values
- Copy order items with metadata between orders – Woocommerce
- Get current user id
- List categories, subcategories and posts from custom taxonomy and custom post type
- How to query for posts (hierarchical custom post type) that have children but are NOT top level?
- Custom post type and custom taxonomy 404 on page 2
- WP Query results showing posts outside of category ID
- tax_query (if the terms are empty)
- Custom post type to lead to single post type instead of shortcode modal
- Display custom post type for specific user
- WordPress WP_Query without query GET parameters
- Update Post Status On Woocommerce Payment Complete
- Cannot get custom posts by category
- Custom Post type loop with ACF not displaying properly
- How to get Custom Post Type with Categories wise in WordPress using wp_query
- Shortcode with WP_Query more than once on one page
- Trying to add a class to post links
- Custom Post Type to replace Woocommerce products – page not found error
- How to Query in WordPress which shows Alphabetic Posts?
- Can’t change posts per page in WordPress Post Type Query
- List latest post out of 2 custom post types
- CPT as Product in WooCommerce
- postsperpage value not being applied
- How to count other posts not having specific taxonomy terms?
- Create a WP_Query where if the first value of the first row is equal to the second compare other value
- I’m trying to create a custom version of the wp_list_authors function that includes custom post types
- Exclude latest post from WP_Query taxonomy term loop
- Pagination for search results of custom post type [duplicate]
- Filter posts of custom post type by meta key in (List All Section)
- Group by custom field value (start and end times)
- Sort results without WP_QUERY?
- WP_Query get post from a category and from another post type
- Using Wp_Query, Json to add Highcharts series data
- Display the current post in browser as the first post in a loop (for a slideshow)
- A faster way to query custom post types with multiple conditions?
- Change permalink for custom_post_type using custom_post_meta (woocommerce)
- New post from database
- How to query Posts from a custom post type which contains a custom taxonomy?
- Creating a Tabbed Widget
- Create query for both custom post type and category
- Post ordering not working with custom field
- Custom Post Type Archive Pagination
- Query Posts that have Custom Taxonomy
- Display post from custom post type
- Custom Plugin – Query CPT – Display Results
- List all Custom Post Type posts excluding certain Taxnomy term
- Running a custom query inside another cpt single and trying to grab a variable
- Searching post types
- Get posts by category name
- Query Posts, order by meta value
- WP_Meta_Query object with conditionals