https://comfykoalas.com.au/cdn/shop/t/63/assets/component-cart-bun…?v=113418542692410228671782910108
1(function(){"use strict";window.initCartBundleUpsell=initCartBundleUpsell;function initCartBundleUpsell(){const buttons=document.querySelectorAll(".cart-bundle-upsell .bundle-upsell-btn");buttons.length!==0&&buttons.forEach(function(btn,index){btn.removeEventListener("click",handleBundleUpsellClick),btn.addEventListener("click",handleBundleUpsellClick)})}function handleBundleUpsellClick(event){const btn=event.target,container=btn.closest(".cart-bundle-upsell");if(!container)return;const variantId=container.dataset.variantId,lineIndex=container.dataset.lineIndex,hasSellingPlan=container.dataset.hasSellingPlan==="true",sellingPlanName=container.dataset.sellingPlanName||"";if(!window.rechargeBundleConfig){alert("Unable to add bundle. Please try again.");return}const config=window.rechargeBundleConfig,variantMap=config.variantMapping.find(function(v){return v.parentVariantId===variantId||v.childVariantId===variantId||v.pantsOnlyVariantId===variantId});if(!variantMap){alert("Unable to add bundle - variant not found. Please try again.");return}btn.classList.add("loading"),btn.textContent="Adding bundle...";var originalItem=null;getCartItemDetails(lineIndex).then(function(item){return originalItem=item,removeFromCart(lineIndex)}).then(function(){return addBundleToCart(config,variantMap,hasSellingPlan,sellingPlanName)}).then(function(){var checkoutUrl="/checkout";window.autoDiscount&&(checkoutUrl+="?discount="+window.autoDiscount),window.location.href=checkoutUrl}).catch(function(error){originalItem?restoreCartItem(originalItem).then(function(){btn.classList.remove("loading"),btn.textContent="Bundle with wipes and Save",alert("Unable to add bundle. Your original item has been restored to the cart."),document.dispatchEvent(new CustomEvent("cart:updated"))}).catch(function(restoreError){btn.classList.remove("loading"),btn.textContent="Bundle with wipes and Save",alert("Unable to add bundle and could not restore your item. Please add it to your cart again.")}):(btn.classList.remove("loading"),btn.textContent="Bundle with wipes and Save",alert("Unable to add bundle. Please try again."))})}function getCartItemDetails(lineIndex){return fetch("/cart.js").then(function(response){if(!response.ok)throw new Error("Failed to fetch cart");return response.json()}).then(function(cart){var item=cart.items[parseInt(lineIndex)-1];if(!item)throw new Error("Cart item not found at index "+lineIndex);return item})}function restoreCartItem(itemDetails){var payload={id:itemDetails.variant_id,quantity:itemDetails.quantity,properties:itemDetails.properties||{}};return itemDetails.selling_plan_allocation&&itemDetails.selling_plan_allocation.selling_plan&&(payload.selling_plan=itemDetails.selling_plan_allocation.selling_plan.id),fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:[payload]})}).then(function(response){if(!response.ok)throw new Error("Failed to restore item to cart");return response.json()})}function removeFromCart(lineIndex){return fetch("/cart/change.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({line:parseInt(lineIndex),quantity:0})}).then(function(response){if(!response.ok)throw new Error("Failed to remove item from cart");return response.json()})}async function addBundleToCart(config,variantMap,hasSellingPlan,sellingPlanName){let nappiesSellingPlan=config.nappiesSellingPlan,wipesSellingPlan=config.wipesSellingPlan;hasSellingPlan&&sellingPlanName&&config.sellingPlanMapping&&config.sellingPlanMapping[sellingPlanName]&&(nappiesSellingPlan=config.sellingPlanMapping[sellingPlanName].nappies,wipesSellingPlan=config.sellingPlanMapping[sellingPlanName].wipes);var bundle={externalProductId:config.bundleProductId,externalVariantId:variantMap.parentVariantId,selections:[{collectionId:config.nappiesCollectionId,externalProductId:config.nappyProductId,externalVariantId:variantMap.childVariantId,quantity:1},{collectionId:config.wipesCollectionId,externalProductId:config.wipesProductId,externalVariantId:config.wipesVariantId,quantity:1}]};if(hasSellingPlan&&(bundle.selections[0].sellingPlan=nappiesSellingPlan,bundle.selections[1].sellingPlan=wipesSellingPlan),typeof recharge>"u"||!recharge.bundle)throw new Error("Recharge SDK not loaded");var dynamicValid=await recharge.bundle.validateDynamicBundle(bundle);if(dynamicValid!==!0)throw console.error("TEST:: validateDynamicBundle failed:",dynamicValid),new Error("Bundle val
1idation failed: "+dynamicValid);var selectionResult=await recharge.bundle.validateBundleSelection(bundle);if(!selectionResult.valid)throw console.error("TEST:: validateBundleSelection failed:",selectionResult.error),new Error("Bundle selection validation failed: "+(selectionResult.error||"Unknown error"));var bundleItems=recharge.bundle.getDynamicBundleItems(bundle,config.bundleProductHandle);return fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:bundleItems})}).then(function(response){if(!response.ok)throw new Error("Failed to add bundle to cart");return response.json()})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",initCartBundleUpsell):initCartBundleUpsell(),document.addEventListener("cart:updated",function(){initCartBundleUpsell()}),document.addEventListener("cart:addons",function(){setTimeout(initCartBundleUpsell,100)}),typeof jQuery<"u"&&jQuery(document).ajaxComplete(function(event,xhr,settings){settings.url&&settings.url.includes("/cart")&&setTimeout(initCartBundleUpsell,200)})})(); 2//# sourceMappingURL=/cdn/shop/t/63/assets/component-cart-bundle-upsell.js.map?v=113418542692410228671782910108
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.