1let hasRunForThreeGlobal=!1,hasRunForFourGlobal=!1;const drawer=document.querySelector("#offerDrawer"),drawerAddBtn=drawer?.querySelector("#drawerAddToCart");customElements.get("product-form")||customElements.define("product-form",class extends HTMLElement{constructor(){super()}connectedCallback(){this.form=this.querySelector("form"),this.form.querySelector("[name=id]").disabled=!1,this.form.addEventListener("submit",this.onSubmitHandler.bind(this)),this.cart=document.querySelector("cart-notification")||document.querySelector("cart-drawer"),this.submitButton=this.querySelector('[type="submit"]'),this.addToCartBtn=this.querySelector(".quick-add__submit")||this.querySelector(".product-form__submit"),this.collectionId=this.dataset.collectionId,this.affiliateProduct=this.dataset.affiliateProduct,document.querySelector("cart-drawer")&&this.submitButton.setAttribute("aria-haspopup","dialog"),this.quiz=document.querySelector("product-quiz"),this.quiz&&(this.quizPopup=this.quiz.querySelector(".quiz__popup-wrapper"),this.quizForm=this.quiz.querySelector(".quiz__form"))}onSubmitHandler(evt){evt.preventDefault(),this.addToCartBtn&&this.addToCartBtn.classList.add("adding-to-cart"),fetch("/cart.json").then(response=>response.json()).then(cartData=>{const inputElement=this.querySelector("form").querySelector("[name=id]").getAttribute("value");var variantIdToCheck=Number(inputElement),matchingItems=cartData.items.filter(item=>item.variant_id===variantIdToCheck),totalQuantity=matchingItems.reduce((total,item)=>total+item.quantity,0);if(document.querySelector("quantity-message")&&setTimeout(()=>{document.querySelector("quantity-message")?.querySelector("noscript").getAttribute("data-cart-count")==3&&hasRunForThreeGlobal==!1&&(hasRunForThreeGlobal=!0,window.confettiShooter())},2e3),totalQuantity<4){if(this.submitButton.getAttribute("aria-disabled")==="true")return;this.handleErrorMessage(),this.submitButton.setAttribute("aria-disabled",!0);const config=fetchConfig("javascript");config.headers["X-Requested-With"]="XMLHttpRequest",delete config.headers["Content-Type"];const formData=new FormData(this.form),progressbarCount=parseInt(this.getAttribute("data-progressBar-count")||"0",10);for(let i=1;i<=progressbarCount;i++){const attr=`data-special-product_${i}`;if(this.getAttribute(attr)){formData.append(`properties[special-product_${i}]`,"true");break}}this.getAttribute("data-product-specific")&&formData.append("properties[product-specific]","true"),this.affiliateProduct==="true"&&formData.append("properties[affiliateProduct]",!0),this.cart&&(formData.append("sections",this.cart.getSectionsToRender().map(section=>section.id)),formData.append("sections_url",window.location.pathname),this.cart.setActiveElement(document.activeElement),formData.append("quantity",document.querySelector("product-info quantity-input input")?.value)),config.body=formData,fetch(`${routes.cart_add_url}`,config).then(response=>response.json()).then(response=>{if(response.status){this.handleErrorMessage(response.description);const soldOutMessage=this.submitButton.querySelector(".sold-out-message");if(!soldOutMessage)return;this.submitButton.setAttribute("aria-disabled",!0),this.submitButton.querySelector("span").classList.add("hidden"),soldOutMessage.classList.remove("hidden"),this.error=!0;return}else if(!this.cart){window.location=window.routes.cart_url;return}var event=new CustomEvent("product:added",{detail:{response,sectionTitle:this.dataset.sectionTitle,blockTitle:this.dataset.blockTitle,collectionName:this.dataset.collectionName}});document.dispatchEvent(event),this.quiz&&(this.quiz.resetQuiz(),this.quizForm.reset()),this.quizPopup&&(document.querySelector("body").classList.remove("no-scroll"),this.quizPopup.classList.add("hidden")),this.error||publish(PUB_SUB_EVENTS.cartUpdate,{source:"product-form"}),this.error=!1;const quickAddModal=this.closest("quick-add-modal");if(quickAddModal)document.body.addEventListener("modalClosed",()=>{setTimeout(()=>{this.cart.renderContents(response)})},{once:!0}),quickAddModal.hide(!0);else if(this.getAttribute("data-isPreOrder")=="true")console.log("hello world"),this.postPreeOrderSubmit(),this.submitPreeOrder(),setTimeout(()=>{this.cart.renderContents(response),this.cart.addFreebie()},4500);else{this.cart.renderContents(response),this.cart.addFreebie(),this.dataset.enableUpsell==="true"&&!sessionStorage.getItem("upsellShownOnce")&&(drawer&&(drawer.classList.add("active"),drawerAddBtn&&(drawerAddBtn.textContent="GO TO CART")),sessionStorage.setItem("upsellShownOnce","true"));
1let collectionProgressbar=document.querySelector("collection-progressbar");collectionProgressbar&&collectionProgressbar.updateProgressBar()}}).catch(e=>{console.error(e)}).finally(()=>{this.submitButton.classList.remove("loading"),this.cart&&this.cart.classList.contains("is-empty")&&this.cart.classList.remove("is-empty"),this.error||this.submitButton.removeAttribute("aria-disabled"),this.addToCartBtn&&this.addToCartBtn.classList.remove("adding-to-cart")})}else this.addToCartBtn&&this.addToCartBtn.classList.remove("adding-to-cart"),alert("Kindly Contact our customer Support team on WhatsApp at +91-9004436043 for bulk buying. Thank you")}).catch(error=>{console.error("Error fetching cart data:",error)})}handleErrorMessage(errorMessage=!1){this.errorMessageWrapper=this.errorMessageWrapper||this.querySelector(".product-form__error-message-wrapper"),this.errorMessageWrapper&&(this.errorMessage=this.errorMessage||this.errorMessageWrapper.querySelector(".product-form__error-message"),this.errorMessageWrapper.toggleAttribute("hidden",!errorMessage),errorMessage&&(this.errorMessage.textContent=errorMessage))}async submitPreeOrder(){const preorderData={Name:window.customerName||"",Email:window.customerEmail||"","Phone Number":window.customerPhone||"","Product Title":this.getAttribute("data-product-title")||"","Product ID":this.getAttribute("data-productId")||"","Variant ID":this.getAttribute("data-variantId")||"","SKU ID":this.getAttribute("data-skuId")||"","Date Of Interaction":this.getAttribute("data-interaction-date")||""};try{const formData=new FormData;Object.entries(preorderData).forEach(([key,value])=>{formData.append(key,value)}),(await fetch("https://script.google.com/macros/s/AKfycbxdUw-mYLk9exl_0UNR_rFh7kVYd9q_qX1GDdV_o8Ce0uzsOBTUapdn9I9HKRqOriv7/exec",{method:"POST",body:formData})).ok?console.log("Form submitted successfully"):console.log("Failed to submit the form. Please try again.")}catch(error){console.error("Error:",error)}}postPreeOrderSubmit(){let cartSummery=document.querySelector(".quantity-message-bottom-container");const successMessage=document.querySelector(".preorder-me-success-message-popup");successMessage.classList.remove("inactive"),cartSummery&&cartSummery.classList.add("hidden"),setTimeout(()=>{successMessage.classList.add("inactive"),cartSummery&&cartSummery.classList.remove("hidden")},4e3);let clevertapData={Product_Name:this.getAttribute("data-product-title")||"",Product_id:this.getAttribute("data-productId")||"",Variant_id:this.getAttribute("data-variantId")||"",Qty:document.querySelector(".quantity__input")?document.querySelector(".quantity__input").value:"1",SKU:this.getAttribute("data-skuId")||"",Product_Link:this.getAttribute("data-product-link")||"",Date_Ordered:this.getAttribute("data-interaction-date")||"",Cart_Value:document.querySelector(".cart-discounted-price").innerHTML||""};dataLayer.push({event:"Pre-Order",Product_Name:this.getAttribute("data-product-title")||"",Product_id:this.getAttribute("data-productId")||"",Variant_id:this.getAttribute("data-variantId")||"",Qty:document.querySelector(".quantity__input")?document.querySelector(".quantity__input").value:"1",SKU:this.getAttribute("data-skuId")||"",Product_Link:this.getAttribute("data-product-link")||"",Date_Ordered:this.getAttribute("data-interaction-date")||"",Cart_Value:document.querySelector(".cart-discounted-price").innerHTML||"",clevertap:clevertapData})}}); 2//# sourceMappingURL=/cdn/shop/t/2242/assets/product-form.js.map?v=137343712298722133461782298447
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.