When Executed ? : This event is triggered before the autocomplete API call.
Purpose: It allows for the modification of the autocomplete API request payload data.
Below are examples illustrating how to utilize this event.
For the autocomplete, 'Relevance' will be the default sort order. If you want to change 'Relevance' to 'sellingPrice', you can write code like this:
window.wizzyConfig.events.registerEvent(window.wizzyConfig.events.allowedEvents.BEFORE_AUTOCOMPLETE_EXECUTED, function (data) {
if(data.sort.length && data.sort[0].field == 'relevance'){
data.sort[0] = {"field": "sellingPrice", "order": "asc"};
}
return data;
});
By default Autocomplete API returns single variant per product, Set this to true if you want Autocomplete API to return all the variants of a product in single API response.
window.wizzyConfig.events.registerEvent(window.wizzyConfig.events.allowedEvents.BEFORE_AUTOCOMPLETE_EXECUTED, function (data) {
data.getAllVariants = "true";
return data;
});
{
"q": "book",
"currency": "INR",
"suggestionsCount": 5,
"includeOutOfStock": "false",
"getAllVariants": "false",
"minQueryLength": 1,
"productsCount": 9,
"sections": "[{\"key\":\"categories\"}]",
"sort": "[{\"field\":\"relevance\",\"order\":\"asc\"}]",
"swatch": "",
"facets": ""
}