<% products.forEach(function(product) { %>
<% if (product.campaign_labels) { %> <%- ejs.render(config.product_label_template, { campaigns: config.product_labels, product_labels: product.campaign_labels }) %> <% } %>
<%- product.title %> <%- ejs.render(config.product_actions_template, { product, config }) %>
<% let discount = ''; const priceField = config.price_field; const includeVat = !config.isVatExcluded; const price = includeVat ? Number(product.price) : Number(product.price_without_vat); const salePrice = Number(product[priceField]); const finalPrice = salePrice > 0 && salePrice < price ? salePrice : price; if (salePrice && price && salePrice < price) { const allowedCurrencies = ['€', '£']; let discountAmount = price - salePrice; if (price > 100 && allowedCurrencies.includes(config.default_currency) && !window.lwDualPrice) { discount = config.format_money((discountAmount).toFixed(2)); } else { discount = `${ Math.floor(discountAmount / price * 100 + 0.1) }%`; } } const finalPriceTag = config.format_money(finalPrice.toFixed(2)); const rrpPriceTag = discount ? config.format_money(price.toFixed(2)) : ''; %> <% if (discount) { %>
<%- config.i18n.discount_label.replace('%1', discount) %>
<% } %>
<%= finalPriceTag %> <% if (rrpPriceTag) { %>
<%- config.i18n.rrp %> <%= rrpPriceTag %>
<%- config.i18n.tooltip_rrp %>
<% } %>
<%- window.lwDualPrice?.render(finalPrice, price); %> <% if (product.energyLabel && product.energyLabelLink) { %> <%- ejs.render(config.product_energy_label_template, { product, energyLabelAlt: config.i18n.energy_label, dataSheetLabel: config.i18n.data_sheet, labelClass: '' }) %> <% } %>
<% }); %>