=== CatCode Smart Search for WooCommerce ===
Contributors: catcodestudio
Tags: woocommerce, product search, live search, typo, sku
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Product search that forgives typos, finds SKUs with or without spaces and dashes and shows live suggestions. No external service.

== Description ==

The standard WooCommerce search looks for the exact letters you typed. "Notebok", "ноутбак", "AB 123-45" instead of "AB12345" — and the shopper sees "No products were found" while the product is right there. Smart Search fixes that without sending your catalogue to an outside service: it keeps its own compact index in your WordPress database and answers from it.

**What shoppers get**

* **Typos are forgiven.** One typo in words of 4–6 letters, two in longer words; swapped letters count as one typo. "Showing results for …" tells the shopper what was searched.
* **SKUs the way people type them.** "AB-123 45", "ab12345" and "AB 12345" all find AB12345; Cyrillic letters that look like Latin ones (А, В, С, Е, Н, К, М, О, Р, Т, Х) are read as Latin. The exact SKU comes first.
* **Ukrainian and Russian spellings together.** "телевізор" finds "Телевизор", "мило" finds "Мыло": і/и/ы, є/е/э, ї, ґ and the apostrophe are matched automatically.
* **Word forms.** "чохли" finds "чохла", "headphones" finds "headphone".
* **Live suggestions** under the search field: product image, price, SKU, the categories the results are in, "All results (N)". Keyboard navigation, works on mobile, no jQuery.
* **Ranked results page.** Name and SKU matches first, then categories and brands; products in stock before sold-out ones. The shopper can still sort by price or popularity.

**What the shop owner gets**

* An index that updates itself when a product, its stock or its category changes; big imports are indexed in the background.
* The first build runs in the background after activation; the shop keeps its standard search until the index is ready.
* A search tester in the admin: type like a shopper, see the results and the time it took.
* WP-CLI: `wp catcode-srch reindex`, `wp catcode-srch search "query"`, `wp catcode-srch stats`.
* A ready-made form: `[catcode_srch_search]`.

**Fast on big catalogues**

A search reads the vocabulary, the entries of the few words it picked and the rows of the winners — never the products table with LIKE. The index lives in five small tables with the keys the queries need.

**Where the data goes**

Nowhere. The index is built from your products and stays in your database; suggestions are served by your own site through the WordPress REST API (`/wp-json/catcode-srch/v1/suggest`). No external requests, no tracking.

== Installation ==

1. Install and activate the plugin. WooCommerce must be active.
2. The index builds in the background (a few minutes for tens of thousands of products). Progress: WooCommerce → Smart Search → Index and test.
3. Suggestions appear under the existing search fields of the theme. To place a form yourself, use the `[catcode_srch_search]` shortcode.

== Frequently Asked Questions ==

= Does it work with my theme's search field? =

Suggestions attach to every field named "s" — the WordPress, WooCommerce and most theme search forms. If your theme uses another field, set its CSS selector in the settings.

= What if the index is not built yet or finds nothing? =

The standard WordPress search runs, exactly as without the plugin.

= Will it slow down my site? =

Pages load one small script and stylesheet; the server is asked only when a shopper types. Indexing happens when products are saved, not when pages are viewed.

= Does it search in descriptions? =

Name, SKU, categories (with parent categories) and brands are searched. These are the fields shoppers search by; descriptions bring many accidental matches.

= Is my data sent anywhere? =

No. Everything happens on your server.

== Changelog ==

= 1.0.0 =
* First release: own index, typo tolerance, SKUs with spaces and dashes, Ukrainian/Russian spelling matching, word forms, live suggestions, ranked results page, admin search tester, WP-CLI commands.
