Skip Navigation

[Resolved] Display products variations in an Orders loop

This support ticket is created 4 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 4 years, 1 month ago.

Assisted by: Waqar.

Author
Posts
#1802679
Captura.PNG

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

#1804385

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