beforeInstantSearchAsyncFunction
Use this hook to run asynchronous work (for example, an external API request) before InstantSearch sets any parameters.
Add several await statements to run tasks in sequence.
Parameters
This hook doesn’t accept parameters.Returns
This hook doesn’t return a value. Return aPromise to delay InstantSearch until your work completes.
Examples
Delay InstantSearch until an async task completes
Delay InstantSearch until an async task completes
Return a
Promise to pause InstantSearch while you run async work.JavaScript
beforeInstantSearchConfigurationOptions
Changes InstantSearch options.
Parameters
Returns
Modified configuration options.
Examples
Customize InstantSearch configuration options
Customize InstantSearch configuration options
Update InstantSearch options before it initializes.
JavaScript
beforeInstantSearchOptions
Changes the following parameters:
Parameters
InstantSearch options with the following properties:
colorsdistinctfacetshitsPerPageselectorsortOrders
Returns
Modified InstantSearch options.
beforeInstantSearchAllowParamsArray
Preserves URL parameters when navigating through the search results.
Parameters
URL parameter names to preserve.
Returns
Modified parameter names.
Examples
Preserve a custom URL parameter
Preserve a custom URL parameter
Add
ref to the allowlist so InstantSearch preserves it in the URL.JavaScript
beforeInstantSearchFiltersString
Changes the filter parameter of the search results page.
Parameters
Default (may be empty).
Returns
Filters to apply.
Examples
Add a filter condition
Add a filter condition
Append a price filter to the existing filter string, if present.
JavaScript
beforeInstantSearchMainTemplate
Template for the main template container.
If you’re using the facet display feature,
include a div with class="ais-facets-container" to display the facets.
Parameters
_defaultTemplate
Default template.
Contains facets and configuration.
html
Tagged template function for rendering HTML.
Returns
template
Template to render.
Examples
Customize the main template
Customize the main template
Return a custom page layout that includes facet, stats, and results containers.
JavaScript
beforeInstantSearchProductTemplate
Template for product hits in the search results.
When using this template,
also call algoliaShopify.helpers.handleItemClick(item) to properly handle events.
Parameters
_defaultTemplate
Default template.
Product hit.
html
Tagged template function for rendering HTML.
InstantSearch components (like
Highlight).Returns
template
Template to render.
Examples
Customize product hits
Customize product hits
Return a custom product-hit template and call
algoliaShopify.helpers.handleItemClick(hit) to track events.JavaScript
beforeInstantSearchNoResultTemplate
Template for when there are no results.
Parameters
_defaultTemplate
Default template.
html
Tagged template function for rendering HTML.
Returns
template
Template to render.
Examples
Customize the no results template
Customize the no results template
Replace the default empty state with a custom template.
JavaScript
beforeInstantSearchStatsTemplate
Template for search stats
Parameters
_defaultTemplate
Default template.
Contains search statistics, for example
nbHits, page, and hitsPerPage.html
Tagged template function for rendering HTML.
Returns
template
Template to render.
Examples
Customize the stats template
Customize the stats template
Customize the stats template for one or many results.
JavaScript
beforeInstantSearchTransformItems
Change items before they’re rendered.
Parameters
Search result items.
Original items.
Returns
Modified items.
Examples
Mark out-of-stock items
Mark out-of-stock items
Set
can_order to false for items with inventory_quantity equal to 0.JavaScript
beforeInstantSearchStartAddWidgets
Add InstantSearch widgets to the search results page.
You can add the following widgets:
rangeSlidermenurefinementListsearchBoxstatssortByclearRefinementspanelhitspaginationconfigure
Returns
InstantSearch widgets.
Examples
Add a custom widget
Add a custom widget
Add a
searchBox widget before InstantSearch adds default widgets.JavaScript
afterInstantSearchStartRemoveDefaultWidgets
Remove default widgets from the search results page.
You can remove these widgets (widget.$$widgetType):
ais.sortByais.searchBoxais.statsais.hitsais.pagination
Parameters
Default InstantSearch widgets.
Returns
Widgets to remove.
Examples
Remove a default widget
Remove a default widget
Remove the default pagination widget.
JavaScript
beforeInstantSearchFacetSearchablePlaceholder
Changes the searchablePlaceholder for facet search.
Use
beforeInstantSearchFacetParamsOptions instead.Parameters
Default placeholder text.
Returns
Modified placeholder text.
Examples
Change the facet search placeholder
Change the facet search placeholder
Override the facet search placeholder text.
JavaScript
beforeInstantSearchFacetParamsOptions
Update widget parameters before they’re rendered.
Parameters
Widget parameters. Parameters depend on the widget type.
Use
facet.type to determine the widget.Facet metadata (read-only):
titlenametype(refinement parameters)slider:rangeSlidermenu:menuconjunctive:refinementListdisjunctive:refinementList
Returns
Modified widget parameters.
Examples
Customize facet widget parameters
Customize facet widget parameters
Adjust facet widget parameters based on
facet.title or facet.type.JavaScript
beforeInstantSearchFacetPanelOptions
Update the panel parameters before they’re rendered.
Parameters
Facet metadata (read-only):
titlename
Returns
Modified panel parameters.
Examples
Customize panel parameters
Customize panel parameters
Customize panel templates like
header, footer, and searchableNoResults.JavaScript
beforeInstantSearchInitSearchSortOrders
Transform sort order before they’re rendered.
Parameters
Sort order objects, each with:
name(string): display name for the sort ordervalue(string): name for the sort order
Returns
Modified sort orders.
Examples
Add a custom sort order
Add a custom sort order
Add a custom sort option to the sort-by widget.
JavaScript
beforeInstantSearchInitCollectionSortOrders
Transform the sort order for collections.
Parameters
Sort order objects, each with:
name(string): display name for the sort ordervalue(string): name for the sort order
Returns
Modified sort orders.
Examples
Add a custom collection sort order
Add a custom collection sort order
Add a custom sort option for collections.
JavaScript
afterInstantSearchHitClickAction (deprecated)
This hook is deprecated.
Use
beforeInstantSearchProductTemplate instead.Parameters
First parameter (unused).
Product search result (hit) that was clicked.
Returns
onClick
Function to run on click.
beforeInstantSearchFacetItemTemplate (deprecated)
This hook is deprecated.
Use
beforeInstantSearchFacetParamsOptions instead.
The refinementList widget can be added as a parameter in the template object.Parameters
_defaultTemplate
Default template.
Facet.
html
Tagged template function for rendering HTML.
beforeInstantSearchShowMoreTemplate (deprecated)
This hook is deprecated.
Use
beforeInstantSearchFacetParamsOptions instead.
The refinementList widget can be added as a parameter within the template object.showMoreText button.
Parameters
_defaultTemplate
Default template.
Contains the
isShowingMore property.html
Tagged template function for rendering HTML.
beforeInstantSearchFacetLimitNumber (deprecated)
This hook is deprecated.
Use
beforeInstantSearchFacetParamsOptions instead.
The refinementList widget can be added as a parameter.limit (default: 10).
Parameters
Default limit.
Returns
New limit.
beforeISFacetSearchablePlaceholderString (deprecated)
This hook is deprecated.
Use
beforeInstantSearchFacetSearchablePlaceholder or
beforeInstantSearchFacetParamsOptions instead.
The searchablePlaceholder option can be added as a parameter in the template object.searchablePlaceholder.
Parameters
Default placeholder text.
Returns
Modified placeholder text.
beforeISFacetSearchableNoResultsString (deprecated)
This hook is deprecated.
Use
beforeInstantSearchFacetParamsOptions instead.
The searchableNoResults option can be added as a parameter in the template object.searchableNoResults.
Parameters
Default “no results” text.
Returns
Modified “no results” text (string or template literal).
beforeInstantSearchFacetHeaderString (deprecated)
This hook is deprecated.
Use
beforeInstantSearchFacetPanelOptions instead.
The header parameter can be added as a parameter in the template object.
To avoid duplicate headers, use the beforeInstantSearchMainTemplate hook and remove the ais-facet-dropdown-wrapper container.Parameters
Default facet header.
Returns
Modified facet header.
beforeInstantSearchFacetTransformItemsOptions (deprecated)
This hook is deprecated.
Use
beforeInstantSearchFacetParamsOptions instead.
Use transformItems as a parameter to transform the data.items before they’re rendered.
Parameters
Transform items options.
Returns
Modified options.
beforeISTransformItems (deprecated)
This hook is deprecated.
Use
beforeInstantSearchTransformItems instead.Parameters
Transformed items.
Original items.
Returns
Modified items.
afterISStartRemoveDefaultWidget (deprecated)
This hook is deprecated.
Use
afterInstantSearchStartRemoveDefaultWidgets instead.widget.widgetType):
ais.sortByais.searchBoxais.statsais.hitsais.pagination
Parameters
Default InstantSearch widgets.
Returns
Widgets to remove.
beforeISearchInitSortOrdersArray (deprecated)
This hook is deprecated.
Use
beforeInstantSearchInitSearchSortOrders instead.sort order before they’re rendered.
Parameters
Sort orders.
Returns
Modified sort orders.
beforeISStartAddWidgetArray (deprecated)
This hook is deprecated.
Use
beforeInstantSearchStartAddWidgets instead.rangeSlidermenurefinementListsearchBoxstatssortByclearRefinementspanelhitspaginationconfigure
Returns
InstantSearch widgets.
beforeISInitCollectionSortOrdersArray (deprecated)
This hook is deprecated.
Use
beforeInstantSearchInitCollectionSortOrders instead.Parameters
Sort orders.
Returns
Modified sort orders.