beforeAutocompleteAsyncFunction
Use this hook to run asynchronous work (for example, external API requests) before Autocomplete continues.
Parameters
This hook doesn’t accept parameters.Returns
This hook doesn’t return a value. Return aPromise to delay Autocomplete until your work completes.
Examples
Delay Autocomplete until an async task completes
Delay Autocomplete until an async task completes
JavaScript
beforeAutocompleteConfigurationOptions
Modifies the global Autocomplete configuration before any plugin executes a .
This hook runs on every keystroke and lets you customize search parameters,
apply a , update analytics tags, or change other search query settings across all Autocomplete sources.
Parameters
Configuration object.
Context information.
Returns
Modified configuration object.
Examples
Add analytics tags to product queries
Add analytics tags to product queries
Add dynamic filters based on query
Add dynamic filters based on query
This example adds the filter
tags:sale to the search,
if the query includes the word sale.JavaScript
beforeAutocompletePluginOptions
Customizes individual plugin options during plugin construction.
This hook runs once per plugin at initialization time.
Use the hook to set static defaults like base filters, analytics tags, or custom transform functions.
Parameters
Plugin options.
Context information.
Returns
Modified plugin options.
Examples
Set base filters per plugin
Set base filters per plugin
JavaScript
Customize hits per page per plugin
Customize hits per page per plugin
JavaScript
beforeAutocompletePluginsArray
Manages the plugin array before creating the Autocomplete instance.
This hook runs once at initialization and lets you add and remove plugins, or reorder the plugin array.
Parameters
List of plugins passed to the Autocomplete instance.
Returns
Modified plugin list.
Examples
Remove articles and pages plugins
Remove articles and pages plugins
This example removes the
articles and pages plugins.JavaScript
beforeAutocompleteOptions
Use this hook to set or change Autocomplete options, such as the placeholder text.
Parameters
Returns
Modified Autocomplete options.
Examples
Change the placeholder text
Change the placeholder text
This example changes the placeholder text.
JavaScript
beforeAutocompleteFiltersString
Use this hook to add or override filters in the Autocomplete menu.
Parameters
Filters.
Returns
Modified filters.
Examples
Return a custom filter
Return a custom filter
This example returns a custom filter instead of the default.
JavaScript
beforeAutocompleteRedirectUrlOptions
Changes the default parameters of the
createRedirectUrlPlugin function.
Parameters
Redirect URL plugin options.
Returns
Modified Redirect URL plugin options.
Examples
Add a custom class to redirect links
Add a custom class to redirect links
This example changes the template for the redirect link by adding a custom CSS class.
JavaScript
beforeAutocompleteMainTemplate
Changes the HTML template that renders the Autocomplete panel.
Use this to render an Autocomplete multi-panel layout.
Parameters
_defaultTemplate
Default template.
Template options including the
html tagged template function.Template elements.
Whether to render query suggestions.
Returns
template
Template to render.
Examples
Render a two-column layout
Render a two-column layout
This example returns a custom two-column layout as template.
JavaScript
beforeAutocompleteMainProductsTemplate
Renders the product section in the Autocomplete menu.
Parameters
_defaultTemplate
Default template.
templateOptions
Template options including the
html tagged template function.Contains the products element.
Returns
template
Template to render.
Examples
Render the products section
Render the products section
JavaScript
beforeAutocompleteNoResultsTemplate
Renders a template when Autocomplete doesn’t return results.
Parameters
_defaultTemplate
Default template.
templateOptions
Template options including the
html and state properties.Returns
template
Template to render.
Examples
Customize the no results panel
Customize the no results panel
JavaScript
beforeAutocompleteHeaderTemplate
Renders a header section at the top of the Autocomplete results panel.
Parameters
_defaultTemplate
Default template.
templateOptions
Template options including the
html and state properties.Resource type.
Returns
template
Template to render.
Examples
Customize the results header
Customize the results header
JavaScript
beforeAutocompleteFooterTemplate
Renders a footer section at the bottom of the Autocomplete results panel.
To render a footer, select the Show See All products option in the Autocomplete search options in your store’s admin.
Parameters
_defaultTemplate
Default template.
templateOptions
Template options including the
html and state properties.Returns
template
Template to render.
Examples
Render a footer with a “See all products” link
Render a footer with a “See all products” link
beforeAutocompleteProductTemplate
Template for rendering each product hit in the Autocomplete results.
If you are using this template, ensure you also call trackSearchAttribution(item) to properly handle events.
Parameters
_defaultTemplate
Default template.
templateOptions
Template options including
html, item, and components.Whether distinct mode is enabled.
Product URL.
trackSearchAttribution
Function to track search attribution.
Returns
template
Template to render.
Examples
Customize product items
Customize product items
JavaScript
beforeAutocompleteArticlesTemplate
Template for rendering each article hit in the Autocomplete results.
Parameters
_defaultTemplate
Default template.
templateOptions
Template options including
html, item, and components.Article URL.
Returns
template
Template to render.
Examples
Customize article items
Customize article items
JavaScript
beforeAutocompleteCollectionsTemplate
Template for rendering each collection hit in the Autocomplete results.
Parameters
_defaultTemplate
Default template.
templateOptions
Template options including
html, item, and components.Collection URL.
Returns
template
Template to render.
Examples
Customize collection items
Customize collection items
JavaScript
beforeAutocompletePagesTemplate
Template for rendering each pages hit in the Autocomplete results.
Parameters
_defaultTemplate
Default template.
templateOptions
Template options including
html, item, and components.Page URL.
Returns
template
Template to render.
Examples
Customize page items
Customize page items
JavaScript
beforeAutocompleteSuggestionsTemplate
Template for rendering each search suggestion in the Autocomplete menu.
Parameters
_defaultTemplate
Default template.
templateOptions
Template options including
html, item, and components.Returns
template
Template to render.
Examples
Customize suggestions
Customize suggestions
JavaScript
beforeAutocompleteProductTransformResponseHits
Modifies the hits before rendering them in the Autocomplete menu.
For more information, see transformResponse.
Parameters
Search results.
Full results from Algolia.
Returns
Modified search results.
Examples
Transform product hits before rendering
Transform product hits before rendering
JavaScript
afterAutocompleteProductClickAction (deprecated)
This hook is deprecated.
Use
beforeAutocompleteProductTemplate instead.Parameters
First parameter (unused).
Product line item that was clicked.