Repository navigation
Search
Once a shop has 12 or more products, a search box appears: at the top of the categories card on a computer, and in the shop's menu on phones and tablets (or everywhere, if the categories are along the top). Smaller shops don't need one, so it stays out of the way. To show it from the start, or never, choose under Settings → Shop → Search, Show the search box. The search page itself, /shop/search, always works.
- Product names, SKUs (a product's own, and its choices'), tags, category names and descriptions.
- Every word has to match, and the start of a word is enough: wish finds wishbone.
- Hidden products are never found.
Results are sorted by Best match to start with:
- An exact part number. If a search is exactly one product's SKU, the customer goes straight to that product.
- Products with every word in their name, those whose name starts with the first word coming first.
- Then products where the words are in the SKU, then a tag, then a category, then the description.
The words searched for are in bold in the results. Customers can also sort by newest, price or name. Each customer sees their own prices (sale and group prices). Search pages are kept out of search engines.
When a search finds nothing, the shop looks for words it doesn't know and tries the nearest one it does: one letter wrong, missing, extra or two swapped for words of 4 to 6 letters, and up to two for longer words. wishbnoe finds wishbone, bering finds bearing and aluminum finds aluminium. The page says Showing results for wishbone, with a link to search for what was typed instead.
The words it knows are the ones in your products for sale: names, descriptions, tags, categories and choices. Words shorter than 4 letters, and anything with a digit in it, are never guessed at, so a part number one digit out finds nothing rather than the wrong part.
After two letters, a list opens under the search box: up to 6 products (with a photo and price) and up to 3 categories, best match first, then See all results. Spelling mistakes are forgiven here too. Arrow keys move through the list, Enter opens the one chosen and Escape closes it. Without JavaScript the box works as an ordinary search.
To switch suggestions off, untick Suggest products and categories as customers type under Settings → Shop → Search.
Search results, the shop's own list and each category get a row of filters once there are 12 or more products to narrow:
- Category, with a count for each (search and the shop's list only). Choosing one shows the categories inside it.
- Price, in up to four bands worked out from what's listed, like Under £10 or £25–£50. Sale and group prices count.
- In stock only. Products selling on backorder count as in stock, as does a product with any choice in stock.
- On sale, with how many are.
Filters are links, so a filtered page can be shared or bookmarked; sorting and page links keep them, and Clear filters takes them all off. On a phone they fold behind a Filter button. Filtered pages are kept out of search engines.
If customers use other words for the same thing, list them under Settings → Shop, Search, one group a line:
alloy = aluminium = alu
fr = front
diff = differential
A search for alloy wishbone then finds Aluminium wishbone. Commas work instead of =. Synonyms work on tags too.
The search report lists searches that found nothing, each with Add a synonym.
The shop uses SQLite's full-text search, which almost every host has. It keeps its own index of the catalogue, and its list of words for spelling mistakes, and brings both up to date by itself on the next search after anything changes. On a host without full-text search, the shop uses a simpler search that finds the same things.