<% var isPopInPanier = config.widget.location.name.includes('Ajout panier'); var optionnalClass = isPopInPanier ? 'xo-pop-in' : ''; let isMobileVersion = document.location.href.includes('m.damart') || document.location.href.includes('m.stg.damart'); if (isMobileVersion){ var max = 2 }else{ var max = 4 } if (recommendations.length < max) { max = recommendations.length } %>
<%= config.widget.title %>
<% for (var i = 0; i < max; i++) { %> <% const isMobileVersion = document.location.href.includes('m.damart') || document.location.href.includes('m.stg.damart'); const { _id, title, url, photo, price, pricenorebate, allPrices, OffrDiscountRate, picto_event, picto_permanent, innovation } = recommendations[i].product; const hasMultiplePrices = Array.isArray(allPrices) && allPrices.length > 1; const isOnSale = pricenorebate && (pricenorebate > price); // current price/promo price const priceParts = String(Number(price).toFixed(2)).split('.'); const integerPrice = priceParts[0]; const centsPrice = priceParts[1] || '00'; // old price - if promo price const pricenorebateParts = String(Number(pricenorebate).toFixed(2)).split('.'); const integerPricenorebate = pricenorebateParts[0]; const centsPricenorebate = pricenorebateParts[1] || '00'; %> <% } %>