Bug: Query loop with post_type=product returns no results after upgrading to Bricks 2.3
I’ve identified the root cause of this bug through Query Monitor analysis and database inspection.
Summary
After upgrading to Bricks 2.3, any query loop with post_type=product returns zero results. The SQL generated contains AND ( 0 = 1 ), which always returns an empty result set. Rolling back to Bricks 2.2 fixes the issue immediately.
Root cause — 3 points
1. New productType control introduced in 2.3 but not visible in the UI
includes/woocommerce/helpers.php defines a new productType control:
php
'productType' => [
'tab' => 'content',
'label' => esc_html__( 'Product type', 'bricks' ),
'type' => 'select',
'options' => wc_get_product_types(),
'multiple' => true,
'placeholder' => esc_html__( 'Select product type', 'bricks' ),
],
This control is not rendered in the builder UI — it does not appear in the query panel. Users cannot see it, set it, or clear it.
2. The value ['all'] is automatically written to the database
Existing query loop elements received productType: ['all'] in their database settings after upgrading to 2.3 — not set by the user, as the control is invisible. Confirmed directly in the database:
s:11:"productType";a:1:{i:0;s:3:"all";}
3. all is not a valid WooCommerce product type term
At line 360, Bricks builds a tax_query using this value:
php
if ( ! empty( $settings['productType'] ) ) {
$tax_query['product_type'] = [
'taxonomy' => 'product_type',
'field' => 'slug',
'terms' => $settings['productType'], // ['all']
];
}
Valid WooCommerce terms for product_type taxonomy are: simple, variable, grouped, external. The term all does not exist. WP_Tax_Query cannot resolve it and converts the entire query to 0 = 1:
sql
WHERE 1=1 AND ( 0 = 1 ) AND wp_posts.post_type = 'product'
Fix
Either skip the tax_query when all is selected, or — since the UI control is not yet implemented — do not write productType to the database for existing elements at all:
php
if ( ! empty( $settings['productType'] ) && ! in_array( 'all', (array) $settings['productType'] ) ) {
$tax_query['product_type'] = [
'taxonomy' => 'product_type',
'field' => 'slug',
'terms' => $settings['productType'],
];
}
Workaround (for users affected right now): clear the productType value directly in the database for affected elements.
Confirmed on: Bricks 2.3, 2.3.1, 2.3.2 + WooCommerce. Does not affect Bricks 2.2.


