1class CartRemoveButton extends HTMLElement{constructor(){super(),this.addEventListener("click",event=>{event.preventDefault(),this.closest("cart-items").updateQuantity(this.dataset.index,0)})}}customElements.define("cart-remove-button",CartRemoveButton);class CartItems extends HTMLElement{constructor(){super(),this.cartTotalValue=0,this.cartTotalDiscount=0,this.cartOriginalPrice=0,this.lineItemStatusElement=document.getElementById("shopping-cart-line-item-status"),this.currentItemCount=Array.from(this.querySelectorAll('[name="updates[]"]')).reduce((total,quantityInput)=>total+parseInt(quantityInput.value),0),this.debouncedOnChange=debounce(event=>{this.onChange(event)},300),this.addEventListener("change",this.debouncedOnChange.bind(this)),this.renderItems(),document.addEventListener("ajaxProduct:added",()=>{this.renderAndShowItems()}),this.updateShippingNotification("cart-shipping-notification")}onChange(event){this.updateQuantity(event.target.dataset.index,event.target.value,document.activeElement.getAttribute("name"))}getSectionItemsToRender(){return["cart-items","cart-shipping-notification","cart-recommendations","cart-note","cart-footer"]}updateCartSections(newHTML){this.getSectionItemsToRender().forEach(item=>{const elementToReplace=document.getElementById(item);elementToReplace&&(elementToReplace.innerHTML=newHTML.getElementById(item).innerHTML,item==="cart-shipping-notification"&&this.updateShippingNotification("cart-shipping-notification"))})}updateShippingNotification(selector){const shippingNotificationWrapper=document.getElementById(selector);if(!shippingNotificationWrapper)return;const shippingNotification=shippingNotificationWrapper.querySelector("[data-free-shipping-notification]");let cartTotal=parseInt(shippingNotification.dataset.cartTotal,10),freeShippingTreshold=parseInt(shippingNotification.dataset.threshold,10),shopCurrency=shippingNotification.dataset.shopCurrency,targetCurrency=shippingNotification.dataset.targetCurrency;if(shopCurrency!==targetCurrency&&(cartTotal=Math.round(cartTotal/(parseFloat(Shopify.currency.rate)||1))),cartTotal>freeShippingTreshold)shippingNotification.classList.add("threshold-reached"),shippingNotification.querySelector("span").innerHTML=window.cartStrings.shipping_free;else{let missingAmount=freeShippingTreshold-cartTotal,message=window.cartStrings.shipping_not_free.replace("[amount]",Woolman.Utils.formatMoney(missingAmount));shippingNotification.classList.remove("threshold-reached"),shippingNotification.querySelector("span").innerHTML=message}}async renderItems(){fetch(`${routes.cart_url}?section_id=main-cart`).then(response=>response.text()).then(responseText=>{const html=new DOMParser().parseFromString(responseText,"text/html");this.updateCartSections(html)}).catch(e=>{console.error(e)})}async renderAndShowItems(){const parentDrawer=this.closest("[data-drawer]");fetch(`${routes.cart_url}?section_id=main-cart`).then(response=>response.text()).then(responseText=>{const html=new DOMParser().parseFromString(responseText,"text/html");this.updateCartSections(html),parentDrawer&&Woolman.ModalsAndDrawers.showModalOrDrawer(parentDrawer.getAttribute("id"))}).catch(e=>{console.error(e)})}async updateQuantity(line,quantity,name){this.enableLoading(line),fetch(`${routes.cart_change_url}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({line,quantity,sections:"main-cart",sections_url:window.location.pathname})}).then(response=>response.json()).then(responseJson=>{const quantityElement=document.getElementById(`Quantity-${line}`),items=document.querySelectorAll(".cart-item");if(responseJson.errors){quantityElement.value=quantityElement.getAttribute("value"),this.updateLiveRegions(line,responseJson.errors);return}const event=new CustomEvent("cart:update",{detail:responseJson});document.dispatchEvent(event);const html=new DOMParser().parseFromString(responseJson.sections["main-cart"],"text/html");this.updateCartSections(html);const lineItem=document.getElementById(`CartItem-${line}`);lineItem&&lineItem.querySelector(`[name="${name}"]`)&&lineItem.querySelector(`[name="${name}"]`).focus()}).catch(error=>{console.error(error)}).finally(()=>{this.disableLoading()})}updateLiveRegions(line,message){const lineItemError=document.getElementById(`Line-item-error-${line}`)||document.getElementById(`CartDrawer-LineItemError-${line}`);lineItemError&&(lineItemError.querySelector(".cart-item__error-text").innerHTML=message,lineItemError.classList.remove("hide")),this.lineItemStatusElement.setAttribute("aria-hidden",!0);const cartStatus=document.getElementById("cart-live-region-text");cartStatus.setAttribute("aria-hidden",!1),setTimeout(()=>{cartStatus.setAttribute("aria-hidden",!0)},1e3)}enableLoading(line){this.classList.add("is-processing"),this.querySelectorAll(`#CartItem-${line} .loading-overlay`).forEach(overlay=>overlay.classList.remove("hidden")),document.activeElement.blur()}disableLoading(){this.classList.remove("is-processing"),this.querySelectorAll(".loading-overlay").forEach(overlay=>overlay.classList.add("hidden"))}}customElements.define("cart-items",CartItems),customElements.get("cart-note")||customElements.define("cart-note",class extends HTMLElement{constructor(){super(),this.addEventListener("keyup",debounce(event=>{const body=JSON.stringify({note:event.target.value});fetch(`${routes.cart_update_url}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body})},300))}}),customElements.get("cart-recommendations")||customElements.define("cart-recommendations",class extends HTMLElement{constructor(){super(),this.loadRecommendations(),document.addEventListener("ajaxProduct:added",this.loadRecommendations.bind(this))}async loadRecommendations(){if(!(!this.dataset.productId||this.dataset.productId===""))try{const url=new URL(location.origin+routes.product_recommendations_url+".json");url.searchParams.set("product_id",this.dataset.productId),url.searchParams.set("limit",this.dataset.limit||10);const res=await fetch(url),{products}=await res.json();if(!products||products.length==0)throw"No product recommendations foun
1d for products in the cart";this.productsContainer=this.querySelector("[data-products-ajax]"),this.productsContainer.innerHTML="",products.forEach(product=>{const template=this.querySelector("#template-recommendation-item").content.firstElementChild.cloneNode(!0),filename=product.featured_image.split("/").pop(),lastDotIndex=filename.lastIndexOf("."),newFilename=`${filename.substring(0,lastDotIndex)}_300x${filename.substring(lastDotIndex)}`,url2=product.featured_image.replace(filename,newFilename);template.querySelector("img").setAttribute("src",url2),template.querySelector(".card-media").setAttribute("href",location.origin+product.url),template.setAttribute("title",product.title),template.querySelector(".card-title a").textContent=product.title,template.querySelector(".card-title a").setAttribute("href",location.origin+product.url),this.productsContainer.appendChild(template)})}catch(error){this.setAttribute("hidden",!0),console.warn(error)}}}); 2//# sourceMappingURL=/cdn/shop/t/43/assets/cart.js.map?v=120900306014184828301768044188
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.