PageSourceSearch

https://bartesian.com/cdn/shop/t/772/assets/2024-custom-toggle-pro…?v=67705643077760162481788878035

js bartesian.com collected 2026-10-01 11:43:46 UTC 3,542 bytes, 2 lines download raw bytes

1customElements.get("custom-toggle-product")||customElements.define("custom-toggle-product",class extends HTMLElement{constructor(){super(),this.initElements(),this.initData(),this.initEvents()}initElements(){this.buttons=this.querySelectorAll("button.product-model-btn"),this.atcButton=this.querySelector(".bundle-btn"),this.selectedCapsuleId=this.querySelector("select")?.value,this.sideCart=document.querySelector("side-cart"),this.shopPayMessage=document.querySelector("shopify-payment-terms"),this.market=this.dataset.market,this.customUpsellCheckbox=this.querySelector("input#custom-upsell"),this.customUpsellProductVariantId=this.customUpsellCheckbox?.checked?this.customUpsellCheckbox.value:null}initData(){const data=JSON.parse(this.querySelector('[type="application/json"]').textContent);[this.machineProduct,...this.capsuleProducts]=data}initEvents(){this.atcButton&&(this.atcButton.addEventListener("click",this.addBundleProd.bind(this)),this.atcButton.hasAttribute("data-button-invalid")||this.atcButton.removeAttribute("disabled")),this.customUpsellCheckbox&&this.customUpsellCheckbox.addEventListener("change",this.handleUpsellChange.bind(this)),this.addEventListener("change",this.updateBundles.bind(this))}handleUpsellChange(event){this.customUpsellProductVariantId=event.target.checked?event.target.value:null}updateBundles(){this.selectedCapsuleId=this.querySelector("select")?.value,this.updateShopPayMessaging(this.selectedCapsuleId)}updateShopPayMessaging(selectedCapsuleId){this.shopPayMessage&&this.shopPayMessage.setAttribute("variant-id",selectedCapsuleId)}async updatePriceByCapsulesSelection(selectedCapsuleHandle){const bundlePriceWithoutDiscounts=document.querySelectorAll(".bundle-price-without-discount"),bundlePriceWithDiscounts=document.querySelectorAll(".bundle-price-with-discount"),selectedCapsuleProduct=this.capsuleProducts.find(product=>product.handle===selectedCapsuleHandle),updatedBundlePrice=((this.machineProduct.price+selectedCapsuleProduct.price)/100).toFixed(2);bundlePriceWithoutDiscounts.forEach(price=>price.textContent=`$${updatedBundlePrice}`),bundlePriceWithDiscounts.forEach(price=>price.textContent=`$${(updatedBundlePrice-40).toFixed(2)}`)}async addBundleProd(){if(this.isAddingToCart)return;this.isAddingToCart=!0,this.updateBundles();const bundleProductIds=[this.machineProduct.variants[0].id];this.selectedCapsuleId&&bundleProductIds.push(Number(this.selectedCapsuleId)),this.customUpsellProductVariantId&&bundleProductIds.push(Number(this.customUpsellProductVariantId));try{this.toggleInProgress(!0);const items=this.createCartItems(bundleProductIds);await this.sideCart.addItemsToCart(items),setTimeout(()=>this.toggleInProgress(!1),1e3)}catch(err){console.error(err),this.toggleInProgress(!1),alert("An error occurred while adding items to the cart.")}finally{this.isAddingToCart=!1}}toggleInProgress(isInProgress){this.atcButton.classList.toggle("inprogress",isInProgress)}createCartItems(bundleProductIds){return bundleProductIds.map(bundleId=>{const capsuleVariant=this.capsuleProducts.flatMap(product=>product.variants).find(variant=>variant.id===bundleId),capsuleCounts={43250198544583:6,43258953957575:6,44121971884231:12,44436485046471:4},properties=capsuleVariant?{_showModifiedPricing:!0,_modifiedPricing:(capsuleVariant.price/100).toFixed(2),_numCapsulesPerBox:capsuleCounts[capsuleVariant.id]||8}:{};return{quantity:1,id:bundleId,properties}})}});
2//# sourceMappingURL=/cdn/shop/t/772/assets/2024-custom-toggle-product-bundle-pdp.js.map?v=67705643077760162481788878035

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.