document.addEventListener("DOMContentLoaded",function () {var check_if_atc = localStorage.getItem("add_to_cart"); if (check_if_atc == 1) {var cart_bubble = document.getElementById("cart-icon-bubble"); // Corrected method name if (cart_bubble) {setTimeout(function(){cart_bubble.click(); // Trigger the click event localStorage.removeItem("add_to_cart");},500);}} // Get all the variant radio buttons const variantRadios = document.querySelectorAll('main#MainContent .product__info-wrapper variant-selects input[type="radio"]'); // Get the slider images const sliderImages = document.querySelectorAll(".product__media-item img"); // Get the media gallery elements const mediaGallery = document.querySelector("media-gallery"); variantRadios.forEach(radio => {radio.addEventListener("change",function () {// Get the image source of the selected variant const selectedImgSrc = this.nextElementSibling.getAttribute("data-img-src"); const selected_val = this.getAttribute("value"); const selected_attr = this.getAttribute("name"); const productInfogrid = this.closest(".product__info-wrapper"); const closestInput = this.closest(".product-form__input"); const labels = closestInput.querySelectorAll(".product-form__label-container .form__label span"); labels.forEach(label => {label.innerHTML = selected_attr + " - " + selected_val;}); const variantSelect = this.closest("variant-selects"); variantSelect.setAttribute("data-options",selected_val); // Assuming `productInfogrid` is already defined as an element const variant_selector_grid = productInfogrid.querySelectorAll(".product-variant-selector-grid"); // Find the first product variant selector const variant_selector = variant_selector_grid[0].querySelector(".product-variant-selector"); // Loop through all options in the variant selector const options = variant_selector.querySelectorAll("option"); options.forEach(function(option) {// Check if the option text matches the selected value if (option.textContent === selected_val) {const variantID = option.value; // Find the .product-form and set the value for .product-variant-id const productForm = productInfogrid.querySelector(".product-form"); const variantIdElement = productForm.querySelector(".product-variant-id"); if (variantIdElement) {variantIdElement.setAttribute("value",variantID);}}}); // Loop through slider images and find the matching one sliderImages.forEach(slideImg => {// Check if the slider image source contains the selected image source (partial match) if (slideImg.getAttribute("src").includes(selectedImgSrc)) {// Get the mediaId (assuming you have this data attribute in the HTML) const mediaId = slideImg.closest(".slider__slide").dataset.mediaId; // Call the setActiveMedia function to update the active slide and handle scrolling if (mediaGallery && mediaId) {mediaGallery.setActiveMedia(mediaId,false,false); // You can adjust the parameters as needed}}});});}); // Add a single event listener to a parent container for delegation document.body.addEventListener("click",async function (e) {// Check if the clicked element is a button within the main product form const button = e.target.closest(".main-product-form .product-form__submit"); if (!button) {return; // Exit if the clicked element is not the target button} e.preventDefault(); const wrapper = button.closest(".product__info-wrapper"); wrapper.classList.add("fadeop"); try {// Locate the form const form = button.closest('form[data-type="add-to-cart-form"]'); if (!form) {throw new Error("Form with 'data-type=add-to-cart-form' not found.");} // Retrieve variant ID and quantity const variantInput = form.querySelector("input.product-variant-id"); const quantityInput = form .closest(".product__info-container") .querySelector('.product-form__quantity input[name="quantity"]'); if (!variantInput || !quantityInput) {throw new Error("Required inputs (variant ID or quantity) are missing.");} const variantID = variantInput.value.trim(); const quantity = parseInt(quantityInput.value,10); if (!variantID || isNaN(quantity) || quantity <= 0) {throw new Error("Invalid variant ID or quantity.");} console.log("Adding to cart:",{variantID,quantity}); // Add item to the cart const addToCartResponse = await fetch("/cart/add.js",{method: "POST",headers: {"Content-Type": "application/json"},body: JSON.stringify({id: variantID,quantity}),}); if (!addToCartResponse.ok) {throw new Error("Failed to add item to cart.");} console.log("Item added to cart."); // Fetch the updated cart const cartResponse = await fetch("/cart.js"); if (!cartResponse.ok) {throw new Error("Failed to fetch cart.");} const cartData = await cartResponse.json(); console.log("Updated cart data:",cartData); // Update UI or reload localStorage.setItem("add_to_cart","1"); setTimeout(() => {window.location.reload();},800);} catch (error) {console.error("Error handling button click:",error);}}); // Select all sticky add-to-cart buttons const stickyAtcButtons = document.querySelectorAll(".sticky-atc .main-product-atc"); stickyAtcButtons.forEach(button => {button.addEventListener("click",async function (e) {e.preventDefault(); // Find the form element closest to the parent container const form = this.closest("#MainContent").querySelector('form[data-type="add-to-cart-form"]'); const variantID = form.querySelector("input.product-variant-id").value; const quantity = parseInt(form.closest(".product__info-container") .querySelector('.product-form__quantity input[name="quantity"]').value,10); if (variantID) {try {// Add the item to the cart const addToCartResponse = await fetch("/cart/add.js",{method: "POST",headers: {"Content-Type": "application/json"},body: JSON.stringify({id: variantID,quantity})}); if (!addToCartResponse.ok) {throw new Error("Error adding to cart");} // Fetch the updated cart const cartResponse = await fetch("/cart.js"); const cartData = await cartResponse.json(); // Log the updated cart data (optional debugging step) console.log(cartData); // Trigger UI changes localStorage.setItem("add_to_cart","1"); setTimeout(() => {window.location.reload();},800);} catch (error) {console.error("Error updating cart:",error);}} else {console.error("Variant ID or quantity is missing");}});}); document.body.addEventListener("click",async function (e) {// Check if the clicked element is a button within the main product form const button = e.target.closest(".product-grid .grid__item .quick-add__submit"); if (!button) {return; // Exit if the clicked element is not the target button} e.preventDefault(); try {// Locate the form const form = button.closest('form[data-type="add-to-cart-form"]'); if (!form) {throw new Error("Form with 'data-type=add-to-cart-form' not found.");} // Retrieve variant ID and quantity const variantInput = form.querySelector('input[name="id"]'); if (!variantInput) {throw new Error("Required inputs (variant ID or quantity) are missing.");} const variantID = variantInput.value.trim(); const quantity = 1; if (!variantID || isNaN(quantity) || quantity <= 0) {throw new Error("Invalid variant ID or quantity.");} console.log("Adding to cart:",{variantID,quantity}); // Add item to the cart const addToCartResponse = await fetch("/cart/add.js",{method: "POST",headers: {"Content-Type": "application/json"},body: JSON.stringify({id: variantID,quantity}),}); if (!addToCartResponse.ok) {throw new Error("Failed to add item to cart.");} console.log("Item added to cart."); // Fetch the updated cart const cartResponse = await fetch("/cart.js"); if (!cartResponse.ok) {throw new Error("Failed to fetch cart.");} const cartData = await cartResponse.json(); console.log("Updated cart data:",cartData); // Update UI or reload localStorage.setItem("add_to_cart","1"); setTimeout(() => {window.location.reload();},800);} catch (error) {console.error("Error handling button click:",error);}});}); $(document).ready(function(){$(".remove_item_btn").on("click",function(event){event.preventDefault(); const button = $(this); const itemIndex = button.data("index"); var totalSaving_old = $(".dicsont_amnt .cart-drawer__totals__row__money").text(); setTimeout(() => {$.getJSON("/cart.json",function(cart) {console.log("Cart Data:",cart); const total_Count = cart.item_count; $("h2.drawer__heading").text("Cart . "+total_Count+" items"); let item = cart.items.find(i => i.id == button.data("item-id")); var saving_amnt = $(`#CartDrawer-Item-${itemIndex} .savingp`).attr("data-save"); if (item) {$(`#Drawer-quantity-${itemIndex}`).val(item.quantity);} else {var cleanedTotalSave = totalSaving_old ? parseFloat(totalSaving_old.replace("\20ac","").replace(/\./g,"").replace(",",".")) : 0; var cleanedsaving_amnt = saving_amnt ? parseFloat(saving_amnt.replace("\20ac","").replace(/\./g,"").replace(",",".")) : 0; var TotalSavinga = cleanedTotalSave - cleanedsaving_amnt; $(".dicsont_amnt .cart-drawer__totals__row__money").text("\20ac" + TotalSavinga.toFixed(2).replace(".",",")); $(`#CartDrawer-Item-${itemIndex}`).remove();} var sub_total = cart.items_subtotal_price / 100; $(".subamnt .cart-drawer__totals__row__money").text("\20ac" + sub_total.toFixed(2).replace(".",",")); if (cart.item_count === 0) {// Add empty cart message or custom HTML $("cart-drawer.drawer").addClass("is-empty"); $(".drawer__inner").html(` <div class="drawer__inner-empty"> <div class="cart-drawer__warnings center"> <div class="cart-drawer__empty-content"> <h2 class="cart__empty-text">Your cart is empty</h2> <a class="drawer__close" href="" aria-label="Close"> <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" class="icon icon-close" fill="none" viewBox="0 0 18 17"> <path d="M.865 15.978a.5.5 0 00.707.707l7.433-7.431 7.579 7.282a.501.501 0 00.846-.37.5.5 0 00-.153-.351L9.712 8.546l7.417-7.416a.5.5 0 10-.707-.708L8.991 7.853 1.413.573a.5.5 0 10-.693.72l7.563 7.268-7.418 7.417z" fill="currentColor"></path> </svg> </a> <a href="/collections/all" class="button">Continue shopping</a> <p class="cart__login-title h3">Have an account?</p> <p class="cart__login-paragraph"> <a href="https://shopify.com/85926019337/account?locale=en&amp;region_country=NL&amp;consent=a0m0p0" class="link underlined-link" target="_blank" rel="noreferrer noopener">Log in</a> to check out faster. </p> </div> </div> </div> `);}});},800);}); $(".drawer__close").on("click",function(){$(this).closest("cart-drawer.drawer").removeClass("active");}); function updatePrice(compare,cartItemId,saving,action) {setTimeout(() => {$.getJSON("/cart.json",function(cart) {console.log("Cart Data:",cart); // Find the cart item using the cart item ID const total_Count = cart.item_count; $("h2.drawer__heading").text("Cart . "+total_Count+" items"); const item = cart.items.find(item => item.id === parseInt(cartItemId)); var totalSaving_old = $(".dicsont_amnt .cart-drawer__totals__row__money").text(); if(item){console.log("Action:",action); var price = (item.original_price * item.quantity) / 100; if(action === "plus" && item.quantity > 1){var cleanedCompare = compare ? parseFloat(compare.replace("\20ac","").replace(/\./g,"").replace(",",".")) : 0; var newqnty = item.quantity - 1; // Multiply cleaned compare price by quantity var totalComparePrice = cleanedCompare / newqnty; var compareprice = totalComparePrice * item.quantity; var cleanedSave = saving ? parseFloat(saving.replace("\20ac","").replace(/\./g,"").replace(",",".")) : 0; var totalSavePrice = cleanedSave / newqnty; var saveprice = totalSavePrice * item.quantity; var cleanedTotalSave = totalSaving_old ? parseFloat(totalSaving_old.replace("\20ac","").replace(/\./g,"").replace(",",".")) : 0; var newTotalsave = cleanedTotalSave + totalSavePrice; console.log("newSave",newTotalsave);} else if(action === "minus" && item.quantity > 0) {var cleanedCompare = compare ? parseFloat(compare.replace("\20ac","").replace(/\./g,"").replace(",",".")) : 0; var newqnty = item.quantity + 1; // Multiply cleaned compare price by quantity var totalComparePrice = cleanedCompare / newqnty; var compareprice = totalComparePrice * item.quantity; var cleanedSave = saving ? parseFloat(saving.replace("\20ac","").replace(/\./g,"").replace(",",".")) : 0; var totalSavePrice = cleanedSave / newqnty; var saveprice = totalSavePrice * item.quantity; var cleanedTotalSave = totalSaving_old ? parseFloat(totalSaving_old.replace("\20ac","").replace(/\./g,"").replace(",",".")) : 0; var newTotalsave = cleanedTotalSave - totalSavePrice;} $(`#price-${cartItemId}`).text("\20ac" + price.toFixed(2).replace(".",",")); $(`#cross-${cartItemId}`).text("\20ac" + compareprice.toFixed(2).replace(".",",")); $(`#saving-${cartItemId}`).text("(You Save: \20ac" + saveprice.toFixed(2).replace(".",",") +")"); $(`#saving-${cartItemId}`).attr("data-save","\20ac" + saveprice.toFixed(2).replace(".",",")); $(".dicsont_amnt .cart-drawer__totals__row__money").text("\20ac" + newTotalsave.toFixed(2).replace(".",",")); var sub_total = cart.items_subtotal_price / 100; $(".subamnt .cart-drawer__totals__row__money").text("\20ac" + sub_total.toFixed(2).replace(".",","));}});},800);} // Event listeners for update on click $(document).on("click",".plus_b",function() {const cartItemId = $(this).data("item-id"); const compare = $(`#cross-${cartItemId}`).text(); const saving = $(`#saving-${cartItemId}`).attr("data-save"); updatePrice(compare,cartItemId,saving,"plus");}); $(document).on("click",".minus_b",function() {const cartItemId = $(this).data("item-id"); const compare = $(`#cross-${cartItemId}`).text(); const saving = $(`#saving-${cartItemId}`).attr("data-save"); updatePrice(compare,cartItemId,saving,"minus");});});{}
/*# sourceMappingURL=/cdn/shop/t/6/assets/custom.css.map */
