Examples
3 min
Modify Response
Below are some common uses of modifying the query response. You can find guides for more elaborate customizations within the How-To section of the Template JS documentation.
Please review : The Modify Response Overview for complete details on the syntax used for modifying the incoming query response.
Modify Datapoints
Product datapoints can be modified before it goes into templating.
klevu.modifyResponse("landing", function(data, scope){
klevu.each(data.template.query.productList.result, function(indx, product)
{
if (indx === 5) {
product.salePrice = '999.00';
}
});
});
Additional Datapoints
Custom datapoints can be added to the product response before it goes into templating. These additional points are commonly used in display or other rendering logic.
klevu.modifyResponse("landing", function(data, scope){
klevu.each(data.template.query.productList.result, function(indx, product)
{
if (indx === 5) {
product.myFlag = true;
}
});
});