PageSourceSearch

https://nervefragrances.com/cdn/shop/t/28/assets/product-upsell-widget.js?v=183550070837311857841787937250

js nervefragrances.com collected 2026-10-04 02:41:20 UTC 3,035 bytes, 2 lines download raw bytes

1class ProductUpsellWidget{constructor(container){this.container=container,this.checkbox=container.querySelector("[data-upsell-toggle]"),this.content=container.querySelector("[data-upsell-content]"),this.variantSelector=container.querySelector("[data-upsell-variant-id]"),this.quantityInput=container.querySelector("[data-upsell-quantity]"),this.redirectToCart=container.dataset.redirectToCart==="true",this.init()}init(){this.checkbox&&(this.checkbox.addEventListener("change",e=>this.toggleContent(e)),this.interceptCartSubmit())}toggleContent(e){e.target.checked?(this.content.style.maxHeight=this.content.scrollHeight+"px",this.content.style.opacity="1"):(this.content.style.maxHeight="0",this.content.style.opacity="0")}interceptCartSubmit(){const mainForm=this.container.closest("product-form")?.querySelector("form")||this.container.closest("form")||document.querySelector('form[action*="/cart/add"]');mainForm&&mainForm.addEventListener("submit",async e=>{this.checkbox.checked&&(e.preventDefault(),e.stopPropagation(),await this.addBothProducts(mainForm))})}async addBothProducts(mainForm){const mainFormData=new FormData(mainForm),mainVariantId=mainFormData.get("id"),mainQuantity=mainFormData.get("quantity")||1,upsellVariantId=this.variantSelector?.value,upsellQuantity=this.quantityInput?.value||1;if(!upsellVariantId){this.showError("Please select a variant for the add-on product");return}const submitBtn=mainForm.querySelector('[type="submit"]'),originalBtnText=submitBtn?.textContent;submitBtn&&(submitBtn.textContent="Adding...");try{const items=[{id:mainVariantId,quantity:parseInt(mainQuantity)},{id:upsellVariantId,quantity:parseInt(upsellQuantity)}],response=await fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items})});if(response.ok)this.refreshCart(),this.redirectToCart&&(window.location.href="/cart");else{const error=await response.json();this.showError(error.message||"Error adding products to cart")}}catch(error){console.error("Cart error:",error),this.showError("Error adding products to cart. Please try again.")}finally{submitBtn&&(submitBtn.textContent=originalBtnText)}}refreshCart(){document.documentElement.dispatchEvent(new CustomEvent("cart:refresh",{bubbles:!0})),window.theme?.cart?.refresh&&window.theme.cart.refresh();const cartDrawer=document.querySelector("cart-drawer");cartDrawer&&typeof cartDrawer.open=="function"&&cartDrawer.open();const cartDrawerAlt=document.querySelector("[data-cart-drawer]");cartDrawerAlt&&cartDrawerAlt.classList.add("is-open")}showError(message){alert(message)}}document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("[data-upsell-widget]").forEach(widget=>new ProductUpsellWidget(widget))}),window.Shopify&&Shopify.theme&&document.addEventListener("shopify:section:load",()=>{document.querySelectorAll("[data-upsell-widget]").forEach(widget=>new ProductUpsellWidget(widget))});
2//# sourceMappingURL=/cdn/shop/t/28/assets/product-upsell-widget.js.map?v=183550070837311857841787937250

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.