Woocommerce product bundles, custom query loop

Hello,

I’m using the WooCommerce plugin “Woo Product Bundle”: WooCommerce Product Bundles
It displays related products to the product on a page, above the “Add to Cart” button.


The problem is that I’d like to add elements and style the displayed products to match my theme.

Ideally, I’d like to create a query loop. By doing so, I could have complete control.

I’d like to create a custom query loop. I followed the recommendations on this page: Query Loop – Bricks Academy
but it’s not working.


Hello @antoineb ,

Try to use the Related product element : it’s easier, unless you have a specific reason to write a custom query loop?

FR 🇫🇷

(Produits associés, dans la catégorie WooCommerce Product après avoir cliqué sur le + dans la barre en haut à gauche).

I tried using related products, but it doesn’t display anything.
I want to create a loop because I want to be able to add elements but control the responsive design.

Could you please share screenshots showing the element’s settings and the result you’re getting?

Actually, I think I understand now. The query loop shows me the product on the page, but I want to loop through its child products.

I just tested it with WooCommerce grouped products, and it’s the same. I can’t figure out how to do it…
How do I create a loop on the parent product page of the group to add the child products to the group page?

On a WooCommerce grouped product, the child products appear above the “Add to cart” button.

solution by Jenn

$product = wc_get_product( '{post_id}');

if ( $product && $product->is_type( 'grouped' ) ) {
  $children_ids = $product->get_children();
} else {
  $children_ids = [0];
}


return [
  'post_type' => ['product'],
  'post__in' => $children_ids
];```