=== Smart Product Filter for WooCommerce ===
Contributors: catcodestudio
Tags: woocommerce, product filter, faceted search, attribute filter, price filter
Requires at least: 6.2
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A faceted product filter that stays fast on a large catalogue: its own index table, honest counts and no reload on every click.

== Description ==

Most WooCommerce filters ask the database the same expensive question on every click — join the attribute tables, join the meta tables, count. On a catalogue of a few thousand products that question takes seconds, and the shopper leaves before the answer arrives.

This plugin keeps its own flat index of "which product carries which value", rebuilt in the background and kept current by every product save. Filtering reads that one table, so the query cost stops growing with the number of attributes.

= Free features =

* Facets from product attributes, from any product taxonomy (categories, tags, brands) and from a custom field.
* Checkboxes, radio buttons, a select, a range slider or a toggle — per facet.
* Price slider in the shop's display currency, an "in stock / out of stock" facet and a rating facet.
* Honest counts next to every value: a count tells you what you will get, and the value you already picked keeps showing its siblings instead of collapsing to itself.
* Values with no products are hidden — or shown greyed out, if you prefer the shopper to see the whole range.
* Numeric values sort as numbers: `1.5 / 2 / 10 / 12.5`, not the alphabetical `1.5 / 10 / 12.5 / 2` every term-sorted filter shows.
* Applying a filter does not reload the page: the listing and the filter block are swapped in place and the URL goes into the browser history, so Back works and the link can be copied and shared.
* Mobile drawer with a "Show N products" button, so the count is visible before the tap.
* Chips for what is currently applied, with a one-click reset.
* Readable URLs: `?ccf=pa_color:червоний;p:100-2500` — one state has exactly one URL, so nothing turns into a duplicate.
* Crawl control out of the box: a filtered view is `noindex,follow` with a canonical back to the clean archive, and the shop keeps its crawl budget.
* Placement as a widget or through the `[catcode_filter]` shortcode.
* Works with the theme's own product grid — the swapped selector is a setting, `ul.products` by default.
* HPOS (custom order tables) compatible.

= Pro features =

* No cap on the number of facets (the free tier renders the first three).
* Colour swatches and image swatches instead of checkboxes.
* Merging duplicate values: `12 В`, `12в` and `12 V` become one checkbox while the products keep their own terms.
* SEO landing pages for a filter combination: a real page with its own H1, title, text and `index,follow`, while every other combination stays out of the index.
* Per-facet search box and a "show more" limit for long value lists.

A fresh install is simply the free tier — nothing Pro turns itself on. Licences are annual (1 to 5 years) and include updates and support for that term.

= Requirements =

* WooCommerce 6.0 or newer
* WordPress 6.2 or newer
* PHP 7.4+

The plugin interface is fully translated into Ukrainian. / Інтерфейс плагіна повністю перекладено українською.

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/catcode-smart-filter/`
2. Activate it in the "Plugins" menu
3. Go to WooCommerce → Розумний фільтр → Фасети and import the attributes you want to filter by
4. Open the "Індекс" tab and press "Перебудувати індекс" once
5. Place the block: the "CatCode: розумний фільтр" widget, or the `[catcode_filter]` shortcode

== Frequently Asked Questions ==

= The filter block does not appear =

It renders only where a product listing does — the shop, a product category or tag archive, and product search results. Check that a facet is imported and active, and that the index has been built at least once (WooCommerce → Розумний фільтр → Індекс).

= Clicking a value reloads the whole page =

The AJAX swap needs to know which element holds the product grid. Most themes use `ul.products`, which is the default; if yours does not, put its selector into "Селектор сітки товарів" in the settings.

= The counts do not match the listing =

Press "Перебудувати індекс". A count and a listing can only disagree when the index is behind the catalogue — after a bulk import that wrote to the database directly, for example.

= Does it work with a page cache? =

Yes. Filtered views carry a query string, so they are served fresh; the clean archive stays cacheable. The counts have their own cache with a lifetime you set.

= Will Google index thousands of filter URLs? =

No. A filtered view is `noindex,follow` with a canonical pointing at the clean archive. Only the combinations you deliberately turn into a landing page (Pro) become indexable.

== Screenshots ==

1. The filter block on a shop page
2. The mobile drawer with the "Show N products" button
3. Facets in the admin: source, widget, logic and order
4. The index tab
5. SEO landing pages for a filter combination

== Changelog ==

= 1.0.0 =
* First release.
