How to add a discount percentage or offer on Tagalys widgets, search & listing pages e.g., 20% OFF?

While customizing the product tile JS template, you can calculate the discount percentage and display a label. The details required to calculate this are available in the product_details variable.

Example code:

if (product_details.sale_price != product_details.price) 
var discount_amount = Math.round(((product_details.price - product_details.sale_price) / product_details.price) * 100);
var $discount = $('<span class="product-discount-percentage">').html(discount_amount + '% OFF');