Hello I am trying to display orders on the product page that belong only to that particular product. I am trying do that with a toolset view. For some reason I can't show only the orders to that belong to that partucular product. Instead all orders are shown. Any idea why?
Hello,
There isn't such a built-in feature within Toolset plugins, since Woocommerce plugin is using a custom database table "wp_woocommerce_order_itemmeta" to store the product ID for order post, it is out the range of Toolset or even WordPress range.
In your case, you might consider custom codes, I have searched it in google, and found this thread:
https://stackoverflow.com/questions/45848249/woocommerce-get-all-orders-for-a-product
For your reference.
Thanks,
what about this?
[wpv-conditional if="( wpv_woo_product_belongs_to_this_order() eq '1' )"]
The wpv_woo_product_belongs_to_this_order() is a PHP function, you can follow our document to setup the [wpv-conditional] shortcode:
https://toolset.com/documentation-category/woocommerce-views/
section "Displaying customers associated with WooCommerce orders"
But I don't think it is a good idea, since that post view, will query all order posts each time, and then in the loop display the items by [wpv-conditional] shortcode, if there are lots of order posts in your website, it will conduct the performance problem.