Hello,
I recently contacted Bricks support by email because I was having a query loop issue. I couldn’t display the products that make up a grouped product in order to create my own cards.
Jenn replied with this:
$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
];
It works perfectly. I created a button for adding items to the cart, but I lost the AJAX functionality (the page doesn’t reload, and the cart opens outside of Canva).
But that’s not a problem because my button displays a WooCommerce notification when an item is added to the cart, so my user gets visual confirmation of the addition.
(This doesn’t work with AJAX buttons; the WooCommerce notifications don’t appear (I think this is because the page doesn’t refresh)).
Then I asked ChatGPT for PHP code for a query loop that returns information about child products, because again, I couldn’t find a native way to do this.
$product = wc_get_product( '{post_id}' );
$children_ids = [];
if ( $product && $product->is_type( 'grouped' ) ) {
$children_ids = array_map( 'absint', $product->get_children() );
}
// Évite une boucle “vide” qui casserait le rendu
if ( empty( $children_ids ) ) {
$children_ids = [ 0 ];
}
return [
'post_type' => [ 'product' ],
'post_status' => 'publish',
'posts_per_page' => -1,
'post__in' => $children_ids,
'orderby' => 'post__in', // conserve l’ordre du produit groupé
];
The goal is to provide all the additional information about the child products on the grouped product page.
What would be interesting is to have both query loops for grouped products.
But also to create two new elements:
- a quantity element that would need to be “connected” via the button’s CSS class
- an “add to cart” button element, but one that wouldn’t be linked to WooCommerce like the current button; it would need to be linked via a CSS class and would retain an “AJAX” behavior
(The current “add to cart” button systematically displays the child products of the grouped products)
I know, it’s a lot…

