If you want to prevent out of stock products from appearing in your search results each product will need to have a field such as
in_stock set to
false, or field defining the amount of stock such as
inventory_quantity, which comes as standard with Shopify integrations.
The next step is to set up a filter. To do this log into Search.io and visit the Relevance menu. Once there click the Advanced tab (see image below) and then paste in the appropriate filter (examples below).
Finally click save and Publish change.
Your search results will no longer show out of stock products!
Filter code examples:
- id: add-filter params: filter: constant: inventory_quantity > 0
- id: add-filter params: filter: constant: in_stock = "false"
You can also add a condition to the filter if there are scenarios where you want search results to display out of stock products. In the example below
enable_inventory_filter needs to be passed in on every query
- id: add-filter params: filter: constant: inventory_quantity > 0 condition: enable_inventory_filter = "true"