Skip to main content

Callbacks

This is a reference for supported callbacks and extension points in the Zoovu Search Plugin. It includes:

  • lifecycle hooks for search, suggestions, rendering, filters and errors
  • templating callbacks (nested under suggestTemplate and resultTemplate)
  • renderer override points for result cards

Each table lists arguments and return requirements so you can implement handlers safely.

Main callbacks

These are the main callbacks available in the search plugin. They cover search, suggest, render, filters and errors.

CallbackDescriptionArgumentsMust return?
preInitBefore plugin is initialized (awaits if a Promise is returned).config objectno
initAfter plugin initializes.-no
suggestChangeAfter autocomplete dataset changes.visible (boolean), datasetno
redirectHandle redirects (result mapping, single result).redirect URLno (return false to cancel)
enterWhen Enter is pressed in search box.search termno
preSearchBefore a search request.term, sorting, search box ref, filters, optionsyes - must return true to execute
postSearchAfter results are rendered.search API responseno
preSuggestBefore a suggest request.query, search box refyes - must return true to execute
searchResultAfter search response is received.API responseno (used for custom SERP rendering)
filterSearchWhen a multiselect filter’s search box input changes.filter id, queryno
closeLayerAfter layover/fullscreen closes.-no
moreResultsAfter “show more” is clicked.count visible, max available, group name, responseno
resultImageErrorAfter result image fails.result cardyes - must return false (hide) or string (URL)
suggestLineAfter an autocomplete item is created.HTML, group name, index, item datano
resultLineAfter a result card is created.result/product data, HTML nodeno
navigationClickAfter result group changes.group nameno
preRenderBefore SERP is rendered.results, API responseno - except if changes should be made
suggestPreRenderBefore autocomplete is rendered.autocomplete blocksno (may return modified)
filterRenderedAfter filters are rendered.-no
searchErrorIf search request fails.-no
suggestPostRenderAfter autocomplete is rendered.-no
imageLoadedAfter SERP image loads.img node, srcno
queryModificationBefore query executes.query, optionsyes - must return final query string
focusAfter search box is focused.event, input valueno
blurAfter search box is blurred.event, input valueno
enterResultAfter autocomplete item is selected.term, link, openInNewTab (bool), box valueno
typeOn search box input.event, valueno
resultsPreloadedAfter next page preloads.API responseno
preloadedResultsRenderedAfter preloaded page renders.API responseno
suggestsLoadedAfter autocomplete data loads.autocomplete blocksno
noResultsLoadedAfter a search or suggest request returns no results.query, context ('search' or 'suggestions'), responseno (return true to retry)
noResultsPageRenderedAfter the no-results page is rendered.-no
singleResultPreRenderCallbackBefore a single search result is rendered.result, variantsno
skeletonLoaderRenderedAfter the skeleton loader is rendered.root DOM nodeno

Templating callbacks

These apply only if you’re using custom HTML templates for results or suggestions. They control when you can edit the template string.

These are nested inside the suggestTemplate or resultTemplate object in the config, not top-level in callbacks.

CallbackDescriptionArgumentsMust return?
preRenderCallbackBefore the suggestion/result template is rendered.template string, data objectno (string may be returned if replacing)
templateBuiltCallbackAfter the template string is built, before insert.template string, data objectyes - must return string if modified
postRenderCallbackAfter the template has been rendered into the DOM.HTML node, data objectno

Renderer methods

To change how search result cards look or behave, you can extend the ProductResultRenderer class and override its methods.

MethodDescriptionArgumentsMust return?
renderMain method: builds wrapper and calls sub-renderers.result, isHidden, groupHTML node
renderContentRenders the main content area (title, description, badges).result, isHiddenHTML node
renderPriceRenders the price section.result, isHiddenHTML node
renderActionsRenders the action buttons (e.g. add to cart).result, isHiddenHTML node
onResultHoverWhen a result is hovered (for animations).result, isHiddenno
onResultSelectWhen a result is selected (for tracking).result, isHiddenno

Product result renderer

The product result renderer handles rendering products and provides additional methods that can be extended or overriden.

MethodDescriptionArgumentsMust return?
findDataPointHelper to find a data point by key.Search result, data point keyData point (an object with key and value) properties or undefined
getPriceDataPointHelper to find a price data point, if the data point key is not explicitly defined, it tries to match the data point with a given setting.Search result, data point key, setting name ('newPrice' or 'oldPrice')The price data point or undefined
getStockDataPointHelper to get stock data point.Search resultStock data point or undefined.
getRatingDataPointHelper to get rating data point.Search resultRating data point or undefined.
getRatingCountDataPointHelper to get rating count data point.Search resultRating count data point or undefined.
createComparisonActionCreates a "add to compare" checkbox.Search resultThe created HTML checkbox node or undefined if comparison isn't enabled.
createZoeChatActionCreates a "chat about product" CTA.Search resultThe created CTA HTML button or undefined if Zoe isn't configured.
renderActionsRenders comparison and zoe chat and appends it to the result card content.Result card HTML node, search resultThe created actions wrapper HTML element or undefined if no actions are enabled.
renderPriceRenders price and appends it to the given wrapper element.Wrapper HTML node, search result, modifier ('grid' or 'list'), attachItemProps flagThe created price wrapper HTML element or undefined if price isn't available.
renderStockRenders the stock information and appends it to the result card content.Result card HTML node, search resultThe stock information wrapper HTML element or undefined if no stock information is available.
renderRatingRenders the rating information and appends it to the result card content.Result card HTML node, search resultThe rating information wrapper HTML element or undefined if no rating information is available.
renderVariantsLabelRenders a variants label and appends it to the result card content.Result card HTML node, search resultThe variants label HTML element or undefined if no variants are available or if thumbnails should be rendered.

All renderers can be overridden by using one of the following callbacks. Each callback receives the respective base renderer class (the default class used by the system) as an argument. You must return a new class definition that extends this base class.

CallbackDescriptionArgumentsMust return?
getCustomResultRendererReplace the default renderer with your own custom implementation.CustomResultRenderer (base class)yes – must return a new class
getContentResultRendererOverride how “content” result types are rendered.ContentResultRenderer (base class)yes – must return a new class
getProductResultRendererOverride how “product” result types are rendered.ProductResultRenderer (base class)yes – must return a new class

Other supported extension points

CallbackDescriptionArgumentsMust return?
addToCartCalled when “Add to cart” is triggered in a result card.SKU, product datano (expected to run your own cart logic)