Hi, I've a WooCommerce site. I want to build a page where I list all the orders with all the products and variations associated.
I've created a view to list Orders, then I've created a child view to display products of each order passing [wpv-ordered-product-ids].
I've also added a custom shortcode to display quantity that I found here:
https://toolset.com/forums/topic/display-woocommerce-order-number-shipping-address-and-ordered-products-quantity/
Now the problem is how to display ordered variations. I've created a child view of the products view and I can display variations using this custom code:
add_filter('wpv_filter_query', function($query_args, $view_settings, $view_id){
if($view_id == 123){
$query_args['post_type'] = 'product_variation';
}
return $query_args;
}, 10, 3);
I found it here: https://toolset.com/forums/topic/filter-view-with-variation-post-id/
But the problem is that it displays the list of all variations of the given product, not the variations that the customer ordered. The quantity shortcode is also not working in this case.
How can I display the variations that the customer ordered and the quantity? I want to display orders variations like on the backend (I attach a screenshot).
cheers
Hi,
Thank you for contacting us and I'd be happy to assist.
There is no built-in feature available in Toolset plugins to achieve this, but you'll find a number of guides online to get the product variations from an order:
https://stackoverflow.com/questions/48390818/get-the-selected-variation-attributes-from-orders-in-woocommerce-3
hidden link
You can use logic from these guides in a custom shortcode and then place it in your view loop for the orders.
regards,
Waqar