PageSourceSearch

https://www.alternix.com/cdn/shop/t/62/assets/cart-notification-clone.js?v=148699448747991317381790687055

js alternix.com collected 2026-09-29 17:26:10 UTC 9,503 bytes, 4 lines download raw bytes

1class SideCartDealMessage extends HTMLElement{constructor(){super();let watch=this.dataset.dealIds,currentCart=this.dataset.cartIds,promos=this.dataset.promoIds,_ids=watch.split(",");_ids.pop(),promos.split(",").pop();let _cart=currentCart.split(",");fetch(window.Shopify.routes.root+"cart.js").then(res=>res.json()).then(res=>{let c=0;res.items.map(i=>({id:i.id.toString(),q:i.quantity})).map(i=>{_ids.includes(i.id)&&(c+=i.q)}),this.setAttribute("data-count",c)})}static get observedAttributes(){return["data-count"]}attributeChangedCallback(name,oldValue,newValue){let dataCount=this.getAttribute("data-count"),_pids=this.dataset.promoIds.split(",");_pids.pop();let _cart=this.dataset.cartIds.split(",");name=="data-count"&&this.validateDeal(dataCount,_cart,_pids)}validateDeal(count,cart,expected){let cap=Number(this.getAttribute("data-cap"));count=Number(count),count>=1&&(this.classList.remove("visually-hidden"),document.querySelector("#promo-freebies-wrapper-sidecart").classList.remove("visually-hidden")),count>=cap&&this.setAttribute("data-qualifies",!0),count>cap?cart.map(c=>{(this.getAttribute("data-deal-ready")=="true"||expected.includes(c))&&(document.querySelector("#promo-freebies-wrapper-sidecart").classList.add("visually-hidden"),this.querySelector("#deal-status").innerHTML="Deal added",document.querySelector("#deal-message-notification-sidecart").classList.add("visually-hidden"))}):(this.setAttribute("data-deal-ready",!1),this.querySelector("#deal-status").innerHTML="Looks like your missing out on a deal!")}}customElements.define("sidecart-deal-message",SideCartDealMessage);class SideCartDealFreebie extends HTMLElement{constructor(){super(),this.addEventListener("click",event=>{event.preventDefault();let _id=this.id.replace("get-","");console.log(_id);let formData={items:[{id:_id,quantity:1}]};fetch(window.Shopify.routes.root+"cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(formData)}).then(response=>response.json()).then(()=>{location.reload(),window.location.href=window.Shopify.routes.root+"cart"}).catch(error=>{console.error("Error:",error)})})}}customElements.define("side-cart-deal-freebie",SideCartDealFreebie);class CartNotificationClone extends HTMLElement{constructor(){super(),this.freeDeliveryCustomEl=document.querySelector("free-delivery"),this.closeBtn=document.querySelector(".cart-notification-clone-close-btn"),this.notificationCustomEl=document.querySelector("cart-notification"),this.notificationClone=document.getElementById("cart-notification-clone"),this.notificationCloneWrapper=document.getElementById("cart-notification-clone-wrapper"),this.notificationCloneProductList=document.getElementById("cart-notification-clone-product-list"),this.notificationCloneSubtotal=document.getElementById("cart-notification-clone-price-subtotal"),this.onBodyClick=this.handleBodyClick.bind(this),this.notificationCloneWrapper.addEventListener("click",e=>{this.handleBodyClick(e)}),this.closeBtn.addEventListener("click",e=>{this.hideClone()}),this.notificationClone.addEventListener("click",e=>{if(e.target.classList.contains("cart-notification-clone-minus-btn")){const quantityInput=e.target.parentElement.querySelector("input");if(e.target.parentElement.setAttribute("inactive",""),+quantityInput.value<2){this.sendUpdateRequest(quantityInput,0,+quantityInput.getAttribute("data-line-index"),"minus");return}this.sendUpdateRequest(quantityInput,+quantityInput.value-1,+quantityInput.getAttribute("data-line-index"),"minus")}if(e.target.classList.contains("cart-notification-clone-plus-btn")){const quantityInput=e.target.parentElement.querySelector("input");e.target.parentElement.setAttribute("inactive",""),this.sendUpdateRequest(quantityInput,+quantityInput.value+1,+quantityInput.getAttribute("data-line-index"),"plus")}})}sendUpdateRequest(quantityInput,newQuantity,lineIndex=0,action){const updateConfig={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({quantity:newQuantity,line:lineIndex})};fetch(`${routes.cart_change_url}`,updateConfig).then(response=>{newQuantity===0&&this.removeProductElement(quantityInput,lineIndex),this.updateQuantity(quantityInput,action),this.updateProductDetails(quantityInput),this.updateSubtotal(),this.freeDeliveryCustomEl.checkDelivery(+this.notificationCloneSubtotal.getAttribute("data-subtotal")),this.notificationCustomEl.fetchCartContents()}).catch(e=>{console.error(e)}).finally(()=>{quantityInput.parentElement.removeAttribute("inactive"),this.addQuantityInputEvents()})}checkCartContents(){this.notificationCloneProductList.querySelectorAll(".cart-notification-product--clone").length<1&&(this.notificationCloneProductList.innerHTML=`
2        <span>${this.notificationCloneProductList.getAttribute("data-cart-empty")}</span>
3      `)}removeProductElement(quantityInput,lineIndex){quantityInput.closest(".cart-notification-product--clone").remove(),this.querySelectorAll(".cart-notification-clone-quantity").forEach(quantity=>{const quantityIndex=+quantity.getAttribute("data-line-index");quantityIndex>lineIndex&&quantity.setAttribute("data-line-index",quantityIndex-1)}),this.checkCartContents()}updateProductDetails(quantityInput){quantityInput.closest("quantity-input").parentElement.querySelectorAll(".cart-notification-product__details-price--clone").forEach(tag=>{const tagMoneyEl=tag.querySelector(".money"),previousTotal=tag.getAttribute("data-product-price-total"),newTotal=(quantityInput.value*+tag.getAttribute("data-product-price")).toFixed(2);tag.setAttribute("data-product-price-total",newTotal),tagMoneyEl.textContent=tagMoneyEl.textContent.replace(previousTotal,newTotal)})}updateSubtotal(){const subTotal=[...this.querySelectorAll(".cart-notification-product__details-new-price")].reduce((acc,productPrice)=>Number(productPrice.getAttribute("data-product-price-total"))+acc,0).toFixed(2),previousTotal=this.notificationCloneSubtotal.getAttribute("data-subtotal");this.notificationCloneSubtotal.textContent=this.notificationCloneSubtotal.textContent.replace(previousTotal,subTotal),this.notificationCloneSubtotal.setAttribute("data-subtotal",subTotal)}updateQuantity(quantityInput,action){action==="plus"&&(quantityInput.value=+quantityInput.value+1),action==="minus"&&(quantityInput.value=+quantityInput.value-1),quantityInput.setAttribute("value",quantityInput.value),fetch(window.Shopify.routes.root+"cart.js").then(res=>res.json()).then(res=>{let _ids=document.querySelector("#deal-message-notification-sidecart").getAttribute("data-deal-ids").split(",");_ids.pop();let c=0;res.items.map(i=>({id:i.id.toString(),q:i.quantity})).map(i=>{_ids.includes(i.id)&&(c+=i.q)}),document.querySelector("#deal-message-notification-sidecart").setAttribute("data-count",c)})}addQuantityInputEvents(){this.notificationCloneQuantities=document.querySelectorAll(".cart-notification-clone-quantity"),this.notificationCloneQuantities.forEach(input=>{input.addEventListener("keyup",e=>{const quantityInput=e.target;setTimeout(()=>{if(e.target.value>0)e.target.parentElement.setAttribute("inactive",""),this.sendUpdateRequest(quantityInput,+quantityInput.value,+quantityInput.getAttribute("data-line-index"));else{e.target.parentElement.setAttribute("inactive",""),this.sendUpdateRequest(quantityInput,0,+quantityInput.getAttribute("data-line-index"),"minus");return}},1e3)})})}showClone(){this.notificationCloneWrapper.classList.add("active"),this.freeDeliveryCustomEl.checkDelivery(+this.notificationCloneSubtotal.getAttribute("data-subtotal")),this.addQuantityInputEvents()}hideClone(){this.notificationCloneWrapper.classList.remove("active")}handleBodyClick(evt){const target=evt.target;target!==this.notificationClone&&!target.closest("#cart-notification-clone")&&this.hideClone()}}customElements.define("cart-notification-clone",CartNotificationClone);class CartNotificationRecommendation extends HTMLElement{constructor(){super(),this.cartRecQuantityWrapper=this.querySelector(".cart-notification-rec-quantity"),this.cartRecQuantityInput=this.cartRecQuantityWrapper.querySelector("input"),this.cartRecProductPrice=this.querySelector(".cart-notification-rec-product-price"),this.cartRecQuantityWrapper.addEventListener("click",e=>{if(e.target.classList.contains("cart-notification-rec-plus-btn")){this.updateQuantity();return}if(e.target.classList.contains("cart-notification-rec-minus-btn")){this.updateQuantity("minus");return}})}resetPrice(){}updatePrice(newQuantity){const oldPrice=this.cartRecProductPrice.getAttribute("data-product-price-total"),newPrice=+this.cartRecProductPrice.getAttribute("data-product-price")*newQuantity;this.cartRecProductPrice.textContent=this.cartRecProductPrice.textContent.replace(oldPrice,newPrice.toFixed(2)),this.cartRecProductPrice.setAttribute("data-product-price-total",newPrice.toFixed(2))}updateQuantity(action="plus"){if(action==="plus"){const newQuantity=+this.cartRecQuantityInput.value+1;this.cartRecQuantityInput.value=newQuantity,this.cartRecQuantityInput.setAttribute("value",newQuantity),this.updatePrice(newQuantity);return}if(action==="minus"&&+this.cartRecQuantityInput.value>1){const newQuantity=+this.cartRecQuantityInput.value-1;this.cartRecQuantityInput.value=newQuantity,this.cartRecQuantityInput.setAttribute("value",newQuantity),this.updatePrice(newQuantity);return}}}customElements.define("cart-notification-recommendation",CartNotificationRecommendation);
4//# sourceMappingURL=/cdn/shop/t/62/assets/cart-notification-clone.js.map?v=148699448747991317381790687055

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.