https://www.lacoquetakids.com/cdn/shop/t/291/assets/tagalys-produc…?v=103741792703284419091789399761
1class TagalysTemplateRenderer{constructor(template,translations){this.template=template,this.translations=translations,this.productData=null}setProductData(productData){this.productData=productData}async renderContainer(){if(!this.productData)return!1;const productMarkup=await this.renderProducts(),noButtonText=!this.productData.buttonText||!this.productData.url;return this.template.replace(/@title/g,this.productData.title||this.productData.name).replace(/@text/g,this.productData.text||"").replace(/@button_url/g,this.productData.url||"#").replace(/@button_text/g,this.productData.buttonText||"").replace(/@sectionMargin/g,this.productData.sectionMargin||"").replace(/@products/g,productMarkup).replace(/data-hideIfNoButtonText/g,noButtonText?'style="display:none !important;"':"")}async fetchCartProductIds(){let cartProductIds=[];try{cartProductIds=(await(await fetch("/cart.js",{method:"GET"})).json()).items.map(item=>item.product_id)}catch(err){console.error("Couldn't fetch the cart, eh?",err)}return cartProductIds}async renderProducts(){const renderedProducts=[],cartProductIds=await this.fetchCartProductIds();return this.productData?.products?.forEach(productDetail=>{cartProductIds.includes(productDetail.id)||renderedProducts.push(this.renderProduct(productDetail))}),renderedProducts.join("")}renderProduct(product){return"<h1>Using default template</h1>"}getCurrency(){return theme.moneyFormat.replace("{{amount_no_decimals}}","").replace("{{amount}}","").replace("{{amount_with_comma_separator}}","")}renderPrice(product){let priceMarkup="";return product.compare_at_price&&product.compare_at_price>product.price?priceMarkup=` 2 <span 3 class="prd-Price_CompareText util-ScreenReaderOnly" 4 data-product-price-compare-text 5 > 6 ${this.translations.regularPrice} 7 </span> 8 9 <s class="prd-Price_ComparePrice" data-product-price-compare> 10 ${this.getCurrency()}${product.compare_at_price} 11 </s> 12 13 <span class="prd-Price_Price prd-Price_Price-sale" data-product-price> 14 ${this.getCurrency()}${product.price} 15 </span> 16 `:product.price_varies?priceMarkup=` 17 <span class="prd-Price_Price" data-product-price> 18 ${this.translations.fromPrice.replace("{{ price }}",this.getCurrency()+product.price)} 19 </span> 20 `:priceMarkup=` 21 <span class="prd-Price_Price" data-product-price> 22 ${this.getCurrency()}${product.price} 23 </span> 24 `,priceMarkup}renderTags(product){if(!product.metafields?.tag||product.sale_price<=product.price)return"";const saleTag=product.sale_price<=product.price?` 25 <span class="prd-Tags_Tag prd-Tags_Tag-sale fz-12_20"> 26 ${this.translations.onSale} 27 </span> 28 `:"",otherTags=[];if(product.metafields?.tag){const tagValue=product.metafields.tag.tag_name.value;let splitTags=[];try{splitTags=JSON.parse(tagValue)}catch{splitTags=[tagValue]}splitTags.forEach(tag=>{otherTags.push(`<span class="prd-Tags_Tag fz-12_20">${tag}</span>`)})}return` 29 <div class="prd-Tags"> 30 ${saleTag} 31 ${otherTags.join("")} 32 </div> 33 `}}class PushCartSuggestedProducts extends TagalysTemplateRenderer{renderQuickBuyOptions(product){const options=[];
33return product.variants.forEach(variant=>{options.push(` 34 <option 35 value="${variant.id}" 36 ${variant.available?"":"data-bis"} 37 > 38 ${variant.title} 39 ${variant.available?"":`| ${this.translations.notifyMe}`} 40 </option> 41 `)}),options.join("")}renderProduct(product){return` 42 <section-async 43 class="psh-CartUpsells_Async" 44 data-section-id="push-cart-upsell-item" 45 data-url=${product.__tagalys_fields.link} 46 aria-busy="true" 47 > 48 <div class="psh-CartUpsells_Card"> 49 <a href="${product.__tagalys_fields.link}" class="psh-CartUpsells_ImageContainer"> 50 <div class="rsp-Image" style="--Image_AspectRatio: 133.37662337661538%;"> 51 <img 52 class="rsp-Image_Image" 53 src="${product.images[0].src}" 54 alt="${product.title}" 55 /> 56 </div> 57 </a> 58 59 <div class="psh-CartUpsells_Content"> 60 <a href="${product.__tagalys_fields.link}" class="psh-CartUpsells_ItemTitle fz-18_22">${product.title}</a> 61 62 ${product.metafields?.filters?.colour?.value?.length?` 63 <p class="psh-CartUpsells_Variant fz-12_20"> 64 Colour: ${product.metafields.filters.colour.value[0]} 65 </p> 66 `:""} 67 68 <div class="psh-CartUpsells_Price fz-12_20"> 69 ... 70 </div> 71 72 <product-card-quickbuy class="psh-CartUpsells_Quickbuy"> 73 <form method="post" 74 action="/cart/add" 75 accept-charset="UTF-8" 76 class="psh-CartUpsells_Form" 77 enctype="multipart/form-data" 78 data-push-cart-form 79 data-product-form 80 data-product-handle="${product.handle}" 81 > 82 <input type="hidden" name="form_type" value="product"> 83 <input type="hidden" name="utf8" value="\u2713"> 84 <input type="hidden" name="quantity" value="1"> 85 <input 86 type="hidden" 87 name="id" 88 value="${product.id}" 89 > 90 91 <div class="psh-CartUpsells_Options"> 92 <div class="psh-CartUpsells_OptionSelectContainer"> 93 <label class="psh-CartUpsells_OptionLabel util-ScreenReaderOnly" for="id" data-product-card-quickbuy-el="label"> 94 ${this.translations.select} 95 </label> 96 <select class="psh-CartUpsells_OptionSelect fz-14_24" name="id" data-product-card-quickbuy-el="select"> 97 <option selected="selected" value=""> 98 ${this.translations.select} 99 </option> 100 101 ${this.renderQuickBuyOptions(product)} 102 </select> 103 </div> 104 </div> 105 106 <button 107 type="submit" 108 class="psh-CartUpsells_Button psh-CartUpsells_Button-add btn-Button btn-Button-secondary" 109 data-disabled="${this.translations.selectButton}" 110 data-enabled="${this.translations.addToCart}" 111 data-product-card-quickbuy-el="button" 112 data-bis="${this.translations.notifyMe}" 113 data-bis-variant-id="" 114 > 115 ${product.available?this.translations.addToCart:this.translations.notifyMe} 116 </button> 117 </form> 118 </product-card-quickbuy> 119 </div> 120 </div> 121 </section-async> 122 `}}class MobileMenuSuggestedProducts extends TagalysTemplateRenderer{renderQuickBuyOptions(product){const options=[];
122return product.variants.forEach(variant=>{options.push(` 123 <option 124 value="${variant.id}" 125 ${variant.available?"":"data-bis"} 126 > 127 ${variant.title} 128 ${variant.available?"":`| ${this.translations.notifyMe}`} 129 </option> 130 `)}),options.join("")}renderProduct(product){return` 131 <section-async 132 class="sec-FeaturedProducts_Async sec-FeaturedProducts_Slide car-Carousel_Slide" 133 data-featured-products-el="slide" 134 data-section-id="mobile-menu-product-item" 135 data-url=${product.__tagalys_fields.link} 136 aria-busy="true" 137 > 138 </section-async> 139 `}}class HomepageFeaturedProducts extends TagalysTemplateRenderer{renderQuickBuyOptions(product){const options=[];return product.variants.forEach(variant=>{options.push(` 140 <option 141 value="${variant.id}" 142 ${variant.available?"":"data-bis"} 143 > 144 ${variant.title} 145 ${variant.available?"":`| ${this.translations.notifyMe}`} 146 </option> 147 `)}),options.join("")}renderQuickBuy(product){return` 148 <product-card-quickbuy class="prd-Card_QuickBuy"> 149 <form method="post" 150 action="/cart/add" 151 accept-charset="UTF-8" 152 class="prd-Card_Form" 153 enctype="multipart/form-data" 154 data-push-cart-form 155 data-product-form 156 data-product-handle="${product.handle}" 157 key="card" 158 novalidate="novalidate" 159 > 160 <input type="hidden" name="form_type" value="product"> 161 <input type="hidden" name="utf8" value="\u2713"> 162 <input type="hidden" name="quantity" value="1"> 163 <div class="prd-Card_Options"> 164 <label class="prd-Card_OptionLabel util-ScreenReaderOnly" for="id" data-product-card-quickbuy-el="label"> 165 ${this.translations.select} 166 </label> 167 <select class="prd-Card_OptionSelect fz-14_24" name="id" data-product-card-quickbuy-el="select"> 168 <option selected="selected" value=""> 169 ${product.tags.includes("giftcard")?this.translations.selectGiftCard:this.translations.select} 170 </option> 171 ${this.renderQuickBuyOptions(product)} 172 </select> 173 <span class="prd-Card_OptionArrow"> 174 <svg viewBox="0 0 10 6" fill="none" xmlns="http://www.w3.org/2000/svg"> 175 <path d="M1 1L5 5L9 1" stroke="currentColor"></path> 176 </svg> 177 </span> 178 </div> 179 <button 180 type="submit" 181 class="prd-Card_Button prd-Card_Button-add btn-Button btn-Button-primary" 182 data-disabled="${this.translations.selectButton}" 183 data-enabled="${this.translations.addToCart}" 184 data-product-card-quickbuy-el="button" 185 data-bis="${this.translations.notifyMe}" 186 data-bis-variant-id="" 187 > 188 ${product.available?this.translations.addToCart:this.translations.notifyMe} 189 </button> 190 </form> 191 </product-card-quickbuy> 192 `}renderProduct(product){return` 193 <section-async 194 class="sec-FeaturedProducts_Slide car-Carousel_Slide" 195 data-featured-products-el="slide" 196 data-section-id="mobile-menu-product-item" 197 data-url=${product.__tagalys_fields.link} 198 aria-busy="true" 199 > 200 </section-async> 201 `}}class TagalysProductRecommendations extends window.BAO.CustomElement(){constructor(){super(),window.BAO.eventBus.addEventListener(window.BAO.EVENTS.PUSH_CART.CHANGED,this.reRender.bind(this))}async reRender(e){const titleToRemove=document.querySelector(".psh-CartUpsells_Title"),elementToRemove=document.querySelector(".psh-CartUpsells_List");titleToRemove&&titleToRemove.remove(),elementToRemove&&elementToRemove.remove(),this.dataset.type==="push-cart"&&(this.dataset.productId=e.detail.state.product_id||e.detail.state.items[0]?.product_id||""),this.initialise()}connectedCallback(){switch(super.connectedCallback(),this.sectionTitle=this.dataset.sectionTitle||!1,this.sectionText=this.dataset.sectionText||!1,this.sectionUrl=this.dataset.sectionUrl||!1,this.sectionMargin=this.dataset.sectionMargin||!1,this.sectionButtonText=this.dataset.sectionButtonText||!1,this.translations={onSale:this.dataset.translationOnSale,regularPrice:this.dataset.translationRegularPrice,fromPrice:this.dataset.translationFromPrice,select:this.dataset.translationSelect,selectGiftCard:this.dataset.translationSelectGiftCard,notifyMe:this.dataset.translationNotifyMe,selectButton:this.dataset.translationSelectButton,addToCart:this.dataset.translationAddToCart,cacheVersion:this.dataset.settingsCacheVersion},this.dataset.type){case"push-cart":this.resultsTemplate=window.BAO.TagalysTemplates.pushCartSuggestedProducts;break;case"mobile-menu":this.resultsTemplate=window.BAO.TagalysTemplates.mobileMenuSuggestedProducts;break;default:this.resultsTemplate=window.BAO.TagalysTemplates.homepageFeaturedProducts;break}}setupListeners(){super.setupListeners(),onTagalysReady(()=>{this.initialise()})}initialise(){const tagalysType=this.dataset.tagalysType||"SmartWidget",tagalysSmartWidgetId=this.dataset.tagalysRecommendationId||window.Tagalys.widgetConfig.widget.smartW
201idgetId,tagalysSimilarProductsId=window.Tagalys.widgetConfig.widget.similarProductsId,tagalysCrossSellingId=window.Tagalys.widgetConfig.widget.crossSellingId,tagalysRecommendationId=this.dataset.tagalysRecommendationId||tagalysSimilarProductsId||tagalysCrossSellingId;if(!tagalysSmartWidgetId||(this.dataset.tagalysType==="Recommendations"||this.dataset.tagalysType==="BoughtAlsoBought")&&!this.dataset.productId&&!this.dataset.cartItems&&!window.Tagalys.widgetConfig.widget.fallbackProductId)return!1;Tagalys.UIWidgets[tagalysType].init(`#${this.dataset.id}`,{productId:this.dataset.productId||this.dataset.cartItems||window.Tagalys.widgetConfig.widget.fallbackProductId,recommendationId:tagalysRecommendationId,widgetId:tagalysSmartWidgetId,templates:{widget:{options:{includeTagalysCSS:!1,request:{},hierarchySeparator:"\u279C",position:!1,minimumCharactersToShowSuggestions:2,maxRecentSearchesCount:5,maxTotalSearchesCount:10,alignToSelector:!1,inheritAlignmentElementWidth:!1},render:()=>{}},product:{render:window.BAO.TagalysLibrary.productRender}},callbacks:{beforeAPICall:this.beforeAPICall.bind(this),onSuccessfulAPICall:this.onSuccessfulAPICall.bind(this),onFailedAPICall:this.onFailedAPICall.bind(this)}})}beforeAPICall(requestParams,helpers){return requestParams}async onSuccessfulAPICall(response,helpers){if(response.name&&response.name!==""&&this.els.title&&(this.els.title.element.textContent=response.name),response.products?.length<=0){this.hidden=!0;return}response.title=this.sectionTitle,response.text=this.sectionText,response.url=this.sectionUrl,response.sectionMargin=this.sectionMargin,response.buttonText=this.sectionButtonText;let renderer;switch(this.dataset.type){case"push-cart":renderer=new PushCartSuggestedProducts(this.resultsTemplate,this.translations);break;case"mobile-menu":renderer=new MobileMenuSuggestedProducts(this.resultsTemplate,this.translations);break;default:renderer=new HomepageFeaturedProducts(this.resultsTemplate,this.translations);break}renderer.setProductData(response);const featuredProductsMarkup=await renderer.renderContainer();this.els.target.element.innerHTML="",this.els.target.element.insertAdjacentHTML("beforeend",featuredProductsMarkup)}onFailedAPICall(response,helpers){}}customElements.get("tagalys-product-recommendations")||customElements.define("tagalys-product-recommendations",TagalysProductRecommendations); 202//# sourceMappingURL=/cdn/shop/t/291/assets/tagalys-product-recommendations.js.map?v=103741792703284419091789399761
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.