How does the logic of the filters work?
WooCommerce Product Filters uses advanced logic to ensure that customers always see relevant results and can find what they're looking for quickly and easily.
This page provides more information about how the plugin works behind the scenes.
Products are retrieved using the following logic:
- Individual filters - 'OR' logic is used when you select multiple options within an individual filter. For example, if you select 'Blue' and 'Red' then all products which are either blue OR red are shown.
- Separate filters - 'AND' logic is used by default across multiple filters. For example, if you select 'Blue' from one filter and 'Large' from another then all products which are both blue AND large are shown. You can change this to use 'OR' logic on the plugin settings page.
If you configure separate filters to use 'OR' logic then we recommend testing the filtering carefully to ensure there are no unexpected results. That's because customers normally expect to narrow down the results when they select products from multiple filters, but the 'OR' logic means that products matching any of their selections will be displayed. For example, imagine that you have a category filter and a pricing slider, and a customer selects Category “X” which contains 10 products. This will display 10 products. If they then use the pricing slider to restrict the price to a certain range, then the filter will display:
- All 10 products from Category “X”, and;
- All other products outside the “X” category that are within the selected price range.
Using 'OR' logic across multiple filters can work for certain use cases, but we recommend testing it carefully to avoid counter-intuitive results like the above example.
Only valid products and options are shown
If the customer is on the Shop page then the filters will display all products in the store. If the customer is within a specific part of the store (e.g. a product category page, or a page listing specific products only created using a plugin such as WooCommerce Product Table or Elementor) then the filters will only display products from the current page. For example:
- If there are 10 color attributes in the overall store but only 5 apply to the products on the current category page, then only these 5 colours will appear.
- The price slider will always show the low-high price for the current products, regardless of the price of other products in the store.
All filters which would yield no results are hidden automatically. This includes:
- Individual terms - e.g. the ‘blue’ attribute.
- Entire filters - e.g. if there is a ‘Color’ filter but none of the products use this attribute then the filter will be hidden; or if there are no ‘Out of stock’ products then the stock toggle will be hidden.
- Entire filter groups - e.g. if you have added a filter group but none of the filters would have results, then it shouldn’t appear at all.
- This only applies when the page first loads. Once the customer has started using the filters, it would be strange to suddenly hide certain filters when no results are available. Instead, the product count changes to 0 and the unavailable filters change to become inactive/greyed out in this scenario.
- In addition, the ‘Uncategorized’ category filter is always hidden, even if it has products in it. This is because it doesn't look professional and we would always recommend adding proper categories for your products.
- The above does not apply when you have enabled 'OR' logic for separate filters. That's because the options in each filter are no longer mutually exclusive, so when the customer selects items from one filter, the options in the other filters do not change.
Filters are listed hierarchically
If you have created a multi-level parent/child structure for your categories or hierarchical taxonomies, then the filter options will be nested hierarchically. This allows customers to see the correct structure so that they can select filter options more logically.
The filters are inter-dependent
The filters are dependent on each other so that when you make one selection, the options in the other filters update so that only what is available appears. The count which appears next to each product will also update.
For example, let’s say that you have 'Color' and 'Size' filters and the Large size is only available in Blue. When you select Red, Large will disappear from the Size filter.