PageSourceSearch

https://betseyjohnson.com/cdn/shop/t/1305/assets/cart-upsell.js?v=170801040270335976221772010520

js betseyjohnson.com collected 2026-09-24 17:34:46 UTC 4,111 bytes, 2 lines download raw bytes

1let productQuantities={};window.addEventListener("DOMContentLoaded",event=>{if(!document.querySelector("cart-drawer")){console.error("EG Cart Upsell: The cart drawer is not activated");return}const initCartUpsell=async(preload=!1)=>{const element=document.querySelector("#eg-cart-upsell"),cartDrawerItems=document.querySelector("cart-drawer-items");element&&!cartDrawerItems.classList.contains("is-empty")&&(document.querySelector("#CartDrawer #eg-cart-upsell")?.remove(),cartDrawerItems.insertAdjacentElement("beforeend",element.cloneNode(!0)),document.querySelector("#CartDrawer #eg-cart-upsell").style.display="block",preload&&(document.querySelector("#CartDrawer #eg-cart-upsell").style.opacity="0.2"),document.querySelectorAll(".swatch-element.custom").forEach(swatchElement=>{const firstRadio=swatchElement.querySelector('input[type="radio"]');if(firstRadio){firstRadio.checked=!0;const productId=firstRadio.dataset.productId;productQuantities[productId]=1}}),document.querySelectorAll('#CartDrawer #eg-cart-upsell input[type="radio"]').forEach(radio=>{radio.addEventListener("change",()=>{document.querySelector("#CartDrawer-CartErrors").style.display="none";const variantImage=radio.dataset.variantImage,variantPrice=radio.dataset.variantPrice,variantTitle=radio.dataset.variantTitle,productId=radio.dataset.productId;variantImage.length&&radio.closest(".eg-cart-upsell-list-item").querySelector("img").setAttribute("src",variantImage),radio.closest(".eg-cart-upsell-list-item").querySelector(".cart-item__price").textContent=variantPrice,radio.closest(".eg-cart-upsell-list-item").querySelector(".cart-item__name").textContent=variantTitle,productQuantities[productId]=1,document.querySelector("#CartDrawer .quantity__input").value=productQuantities[productId]})}),document.querySelector("#CartDrawer #eg-cart-upsell").addEventListener("click",async event2=>{const btn=event2.target.closest(".upsell-btn");if(!btn)return;event2.preventDefault(),btn.classList.add("loading"),btn.querySelector(".loading-overlay__spinner").classList.remove("hidden");const selectedRadio=btn.closest(".eg-cart-upsell-list-item").querySelector('input[type="radio"]:checked'),variantId=selectedRadio?selectedRadio.dataset.variantId:null;if(variantId){const addResponse=await fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:variantId,quantity:productQuantities[variantId]||1})});if(!addResponse.ok){console.error("Error adding item to cart:",addResponse.statusText);return}productQuantities[variantId]=productQuantities[variantId]?productQuantities[variantId]+1:1,document.querySelector("#CartDrawer .quantity__input").value=productQuantities[variantId],document.querySelector('#CartDrawer [name="updates[]"]').dispatchEvent(new Event("change",{bubbles:!0}))}else console.error("No variant selected")}))};initCartUpsell();const loadAjaxContent=async()=>{const data=await(await fetch(window.location.href)).text(),newCartUpsell=new DOMParser().parseFromString(data,"text/html").querySelector("#eg-cart-upsell");newCartUpsell&&(document.querySelector("#CartDrawer #eg-cart-upsell")?.remove(),document.querySelector("cart-drawer-items").insertAdjacentElement("beforeend",newCartUpsell),initCartUpsell())};(async()=>{const onMutation=async mutations=>{for(const mutation of mutations)if(mutation.type==="childList")for(const addedNode of mutation.addedNodes)(addedNode.classList?.contains("drawer__inner")||addedNode.classList?.contains("drawer__header"))&&(initCartUpsell(!0),await loadAjaxContent(),initCartUpsell(!1))};new MutationObserver(onMutation).observe(document.querySelector("#CartDrawer"),{childList:!0,subtree:!0})})()}),$(document).ready(function(){console.debug("Slick initializing",$("#eg-cart-upsell-list")),$("#eg-cart-upsell-list").slick({slidesToShow:3,slidesToScroll:1,prevArrow:$(".n-prev-arrow"),nextArrow:$(".n-next-arrow"),responsive:[{breakpoint:768,settings:{infinite:!1,slidesToShow:2}},{breakpoint:480,settings:{infinite:!1,slidesToShow:1}}]})});
2//# sourceMappingURL=/cdn/shop/t/1305/assets/cart-upsell.js.map?v=170801040270335976221772010520

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.