# WooCommerce

The WarpSearch plugin indexes WooCommerce products into a WarpSearch collection and serves product search from it, with as-you-type results and optional replacement of the standard store search. It is open source (GPL) on [GitHub](https://github.com/warpsearchio/warpsearch-woocommerce) and tested with WordPress 7.1, WooCommerce 11.2 (HPOS) and PHP 8.3.

## How it works

- One document per product. Variations are folded into the parent (SKUs, price list, attribute values).
- Saving, trashing or changing stock on a product re-indexes it. Failed writes are retried through Action Scheduler or WP-Cron.
- Results come back as product ids and are hydrated from WordPress, so prices, images and visibility are always current.
- A reindex stamps each document with a run id and deletes this index's documents from older runs at the end, so search stays complete while it runs.

## Install

1. Create a collection and a writer key as described in the [shared setup](integrations.md).
2. Download `warpsearch-for-woocommerce-<version>.zip` from the [latest release](https://github.com/warpsearchio/warpsearch-woocommerce/releases/latest), upload it under **Plugins > Add New > Upload Plugin** and activate it. WooCommerce is required. Composer sites can use `composer require warpsearch/warpsearch-for-woocommerce`.
3. Go to **WooCommerce > WarpSearch**, enter the collection and keys, and click **Test connection**.
4. Click **Reindex all products**, or run `wp warpsearch reindex`.
5. Show results with the WarpSearch block, the `[warpsearch_products]` shortcode, or enable **Replace store search** to answer WordPress product searches from WarpSearch.

## Settings

| Setting | Purpose |
|---|---|
| Endpoint, collection, writer key | The WarpSearch connection. |
| Search key | Optional separate key used for searching; defaults to the server-held writer key. |
| Index name | Lets several sites share one collection. |
| Batch size, results per page | Keep them within your plan's [limits](limits-and-errors.md). |

## WP-CLI

```bash
wp warpsearch reindex
wp warpsearch index 123 456
wp warpsearch status
```

## Good to know

- Search is also available at `/wp-json/warpsearch/v1/search`.
- Only the category facet is queried today. Price and attribute facets are indexed for later.
- Uninstalling removes the plugin's options and schedules but not the documents in WarpSearch.
- The merchant or site operator deploys this plugin on WordPress and maintains Action Scheduler/WP-Cron; no separate connector server is required.
- The repository includes PHP lint/unit checks and a disposable-site live harness. PHP and live-store verification are still outstanding; do not interpret the presence of tests as a release verification result.
