<% var isPopInPanier = config.widget.location.name.includes('Pop-in'); 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 } if (recommendations[0].strategy == "basic-mostPopular") { config.widget.title = "Best Sellers" } %> <% console.log(recommendations) %>
<%= 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, sale_price, allPrices, OffrDiscountRate, Loc_Event_Sticker, Loc_Permanent_Sticker, innovation } = recommendations[i].product; const hasMultiplePrices = Array.isArray(allPrices) && allPrices.length > 1; const isOnSale = sale_price < 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(sale_price).toFixed(2)).split('.'); const integerPricenorebate = pricenorebateParts[0]; const centsPricenorebate = pricenorebateParts[1] || '00'; %> <% } %>