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
andresultTemplate
) - 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.
Callback | Description | Arguments | Must return? |
---|---|---|---|
preInit | Before plugin is initialized (awaits if a Promise is returned). | config object | no |
init | After plugin initializes. | - | no |
suggestChange | After autocomplete dataset changes. | visible (boolean), dataset | no |
redirect | Handle redirects (result mapping, single result). | redirect URL | no (return false to cancel) |
enter | When Enter is pressed in search box. | search term | no |
preSearch | Before a search request. | term, sorting, search box ref, filters, options | yes - must return true to execute |
postSearch | After results are rendered. | search API response | no |
preSuggest | Before a suggest request. | query, search box ref | yes - must return true to execute |
searchResult | After search response is received. | API response | no (used for custom SERP rendering) |
filterSearch | When a multiselect filter’s search box input changes. | filter id, query | no |
closeLayer | After layover/fullscreen closes. | - | no |
moreResults | After “show more” is clicked. | count visible, max available, group name, response | no |
resultImageError | After result image fails. | result card | yes - must return false (hide) or string (URL) |
suggestLine | After an autocomplete item is created. | HTML, group name, index, item data | no |
resultLine | After a result card is created. | result/product data, HTML node | no |
navigationClick | After result group changes. | group name | no |
preRender | Before SERP is rendered. | results, API response | no - except if changes should be made |
suggestPreRender | Before autocomplete is rendered. | autocomplete blocks | no (may return modified) |
filterRendered | After filters are rendered. | - | no |
searchError | If search request fails. | - | no |
suggestPostRender | After autocomplete is rendered. | - | no |
imageLoaded | After SERP image loads. | img node, src | no |
queryModification | Before query executes. | query, options | yes - must return final query string |
focus | After search box is focused. | event, input value | no |
blur | After search box is blurred. | event, input value | no |
enterResult | After autocomplete item is selected. | term, link, openInNewTab (bool), box value | no |
type | On search box input. | event, value | no |
resultsPreloaded | After next page preloads. | API response | no |
preloadedResultsRendered | After preloaded page renders. | API response | no |
suggestsLoaded | After autocomplete data loads. | autocomplete blocks | no |
noResultsLoaded | After a search or suggest request returns no results. | query, context ('search' or 'suggestions'), response | no (return true to retry) |
noResultsPageRendered | After the no-results page is rendered. | - | no |
singleResultPreRenderCallback | Before a single search result is rendered. | result, variants | no |
skeletonLoaderRendered | After the skeleton loader is rendered. | root DOM node | no |
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
.
Callback | Description | Arguments | Must return? |
---|---|---|---|
preRenderCallback | Before the suggestion/result template is rendered. | template string, data object | no (string may be returned if replacing) |
templateBuiltCallback | After the template string is built, before insert. | template string, data object | yes - must return string if modified |
postRenderCallback | After the template has been rendered into the DOM. | HTML node, data object | no |
Renderer methods
To change how search result cards look or behave, you can extend the ProductResultRenderer
class and override its methods.
Method | Description | Arguments | Must return? |
---|---|---|---|
render | Main method: builds wrapper and calls sub-renderers. | result, isHidden, group | HTML node |
renderContent | Renders the main content area (title, description, badges). | result, isHidden | HTML node |
renderPrice | Renders the price section. | result, isHidden | HTML node |
renderActions | Renders the action buttons (e.g. add to cart). | result, isHidden | HTML node |
onResultHover | When a result is hovered (for animations). | result, isHidden | no |
onResultSelect | When a result is selected (for tracking). | result, isHidden | no |
Product result renderer
The product result renderer handles rendering products and provides additional methods that can be extended or overriden.
Method | Description | Arguments | Must return? |
---|---|---|---|
findDataPoint | Helper to find a data point by key. | Search result, data point key | Data point (an object with key and value ) properties or undefined |
getPriceDataPoint | Helper 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 |
getStockDataPoint | Helper to get stock data point. | Search result | Stock data point or undefined . |
getRatingDataPoint | Helper to get rating data point. | Search result | Rating data point or undefined . |
getRatingCountDataPoint | Helper to get rating count data point. | Search result | Rating count data point or undefined . |
createComparisonAction | Creates a "add to compare" checkbox. | Search result | The created HTML checkbox node or undefined if comparison isn't enabled. |
createZoeChatAction | Creates a "chat about product" CTA. | Search result | The created CTA HTML button or undefined if Zoe isn't configured. |
renderActions | Renders comparison and zoe chat and appends it to the result card content. | Result card HTML node, search result | The created actions wrapper HTML element or undefined if no actions are enabled. |
renderPrice | Renders price and appends it to the given wrapper element. | Wrapper HTML node, search result, modifier ('grid' or 'list' ), attachItemProps flag | The created price wrapper HTML element or undefined if price isn't available. |
renderStock | Renders the stock information and appends it to the result card content. | Result card HTML node, search result | The stock information wrapper HTML element or undefined if no stock information is available. |
renderRating | Renders the rating information and appends it to the result card content. | Result card HTML node, search result | The rating information wrapper HTML element or undefined if no rating information is available. |
renderVariantsLabel | Renders a variants label and appends it to the result card content. | Result card HTML node, search result | The 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.
Callback | Description | Arguments | Must return? |
---|---|---|---|
getCustomResultRenderer | Replace the default renderer with your own custom implementation. | CustomResultRenderer (base class) | yes – must return a new class |
getContentResultRenderer | Override how “content” result types are rendered. | ContentResultRenderer (base class) | yes – must return a new class |
getProductResultRenderer | Override how “product” result types are rendered. | ProductResultRenderer (base class) | yes – must return a new class |
Other supported extension points
Callback | Description | Arguments | Must return? |
---|---|---|---|
addToCart | Called when “Add to cart” is triggered in a result card. | SKU, product data | no (expected to run your own cart logic) |