Browser: Version 141.0.7390.55 (Official Build) (arm64)
OS: macOS
URL: Παιδικές Μπλούζες - MyBabyLand
1. Main Goal
I want the native Bricks Filter element on my WooCommerce archive pages to work correctly with variable products. When a user filters by a specific product attribute (like Size “M”), the results should only show products where the “M” variation is currently in stock.
2. The Core Problem
The Bricks AJAX filtering functionality is not respecting the stock status of individual product variations. When a filter is applied, the initial result loaded via AJAX incorrectly includes products where the selected variation is out of stock.
3. Troubleshooting Steps Taken (What We Have Tried)
We have attempted to solve this issue with multiple methods, all of which have failed to fix the AJAX behavior.
Attempt #1: Modifying the Query with Standard WordPress/WooCommerce Hooks
We used several PHP code snippets with hooks like pre_get_posts and woocommerce_product_query to modify the product query.
Result: This worked only on a full page reload, but the AJAX filter results were still incorrect.
Attempt #2: Using the Bricks-Specific Hook
We used the recommended bricks/posts/query_vars PHP filter to modify the query.
Result: Same as above. It only worked on a page refresh, not during the AJAX call.
Attempt #3: JavaScript-Forced Reload
We tried a workaround to force a page reload after the AJAX completes. We created a JavaScript function (forceReloadAfterFilter) and tried to trigger it using:
- A general event listener for bricks.posts.updated.
- The native Bricks Interactions panel (Trigger: Query AJAX loader complete → Action: JavaScript (Function)).
Result: This solution did not work as expected and felt overly complex.
Attempt #4: Hiding Out-of-Stock Variations Globally (Fundamental Approach)
We changed our strategy to hide out-of-stock variations from WooCommerce entirely, so the filters wouldn’t see them.
- We used the woocommerce_variation_is_visible PHP filter to hide variations if !$variation->is_in_stock().
- When that didn’t work, we made the logic more direct, hiding variations if their stock quantity was _stock_quantity <= 0.
Result: Incredibly, even this did not solve the issue. The out-of-stock variations still seem to be visible to the Bricks filter during the AJAX request.
Attempt #5: Standard Debugging
We have confirmed the issue is not caused by:
- Caching: All server, plugin, and browser caches have been cleared repeatedly.
- Product Settings: Variations are correctly set to “Out of stock” and “Do not allow backorders.”
- Plugin Conflicts: We deactivated all other plugins, and the issue persisted.
4. Summary for Support
In short, the Bricks AJAX filter does not correctly check the stock status of product variations. Standard PHP fixes work on a page refresh but are ignored by the AJAX handler. Even hiding the variations at the core WooCommerce level doesn’t seem to stop the AJAX filter from finding them. We need a reliable way to make the AJAX results match the results of a full page load.
