Skip to main content

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 a Promise to delay Autocomplete until your work completes.

Examples

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

config
object
Configuration object.
context
object
Context information.

Returns

config
object
Modified configuration object.

Examples

This example adds the tags autocomplete, products, and v2 to the search query for products only.
JavaScript
This example adds the filter tags:sale to the search, if the query includes the word sale.
JavaScript
This example adds custom ruleContexts to the product queries in Autocomplete.
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

options
object
Plugin options.
context
object
Context information.

Returns

options
object
Modified plugin options.

Examples

JavaScript
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.
To work with plugins, use the arguments object to extract them into an array.

Parameters

...plugins
any[]
List of plugins passed to the Autocomplete instance.

Returns

plugins
any[]
Modified plugin list.

Examples

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

options
object
Modified Autocomplete options.

Examples

This example changes the placeholder text.
JavaScript

beforeAutocompleteFiltersString

Use this hook to add or override filters in the Autocomplete menu.

Parameters

filters
string
Filters.

Returns

filters
string
Modified filters.

Examples

This example returns a custom filter instead of the default.
JavaScript

beforeAutocompleteRedirectUrlOptions

Changes the default parameters of the createRedirectUrlPlugin function.

Parameters

options
object
Redirect URL plugin options.

Returns

options
object
Modified Redirect URL plugin options.

Examples

beforeAutocompleteMainTemplate

Changes the HTML template that renders the Autocomplete panel. Use this to render an Autocomplete multi-panel layout.

Parameters

_defaultTemplate
Default template.
templateOptions
object
Template options including the html tagged template function.
elements
object
Template elements.
displaySuggestions
boolean
Whether to render query suggestions.

Returns

template
Template to render.

Examples

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.
elements
object
Contains the products element.

Returns

template
Template to render.

Examples

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

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
string
Resource type.

Returns

template
Template to render.

Examples

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

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.
distinct
boolean
Whether distinct mode is enabled.
Product URL.
trackSearchAttribution
Function to track search attribution.

Returns

template
Template to render.

Examples

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

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

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

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

JavaScript

beforeAutocompleteProductTransformResponseHits

Modifies the hits before rendering them in the Autocomplete menu. For more information, see transformResponse.

Parameters

hits
array
Search results.
results
object
Full results from Algolia.

Returns

hits
array
Modified search results.

Examples

JavaScript

afterAutocompleteProductClickAction (deprecated)

This hook is deprecated. Use beforeAutocompleteProductTemplate instead.
Adds a click handler function to the product template. Call this hook after a user clicks a product.

Parameters

_
any
First parameter (unused).
line_item
object
Product line item that was clicked.

See also

Last modified on May 19, 2026