Exclusive Basket Offers

 Added to cart

${obj.title}

${quantity} x ${select_varient_name}
 Added to cart

${obj.title}

${quantity} x ${select_varient_name}
This is error
${products[i].title}
 ${symbol} ${priceRoundingExists && priceRounding === 'enabled' ? roundToNearestMultiple(products[i].priceRangeV2.minVariantPrice.amount*currencyRate , roundingFactor) : (products[i].priceRangeV2.minVariantPrice.amount*currencyRate).toFixed(2)}
${products[i].description}
 ${symbol} ${priceRoundingExists && priceRounding === 'enabled' ? roundToNearestMultiple(products[i].priceRangeV2.minVariantPrice.amount*currencyRate , roundingFactor) : (products[i].priceRangeV2.minVariantPrice.amount*currencyRate).toFixed(2)}
` if (variants.length > 1) { childElement.innerHTML += `
`; childElementModal.innerHTML+=`
` } else { childElement.innerHTML += `
${products[index].options[a].name}
`; } } currentModal.innerHTML+=`
.
` const button = currentModal.querySelector('button'); currentModal.removeChild(button); currentModal.appendChild(button); const form = currentModal.closest('form'); if(form){ const formData = new FormData(form); let id = searchInMetafield(formData , index ); } } varaintSubmit= [...document.getElementsByClassName('submitVaraint')]; for(let x = 0 ; x < varaintSubmit.length ; x++){ varaintSubmit[x].addEventListener('click', function(e) { varaintSubmit = varaintSubmit.sort(function(a, b) { let indexA = parseInt(a.getAttribute('index')); let indexB = parseInt(b.getAttribute('index')); return indexA - indexB; }); e.preventDefault(); let index = varaintSubmit[x].getAttribute("index"); const form = e.target.closest('form'); if(form){ const formData = new FormData(form); let id = searchInMetafield(formData , index); let btn = document.getElementById(`submitVaraint${index}`); if(id != null){ btn.disabled = true; btn.style.cursor = 'not-allowed'; btn.textContent = 'Adding'; btn.style.backgroundColor = 'rgba(0, 0, 0, 0.5)'; handleButtonClick(id , btn , true , index); } } }); } window.addEventListener('scroll', function() { let elem = document.getElementById('mainProdUpsell'); let header = document.getElementsByClassName('header')[0]; elem.style.zIndex = 9999; if (window.scrollY != 0 && window.innerWidth > 768) { header.style.display = 'none'; } else { header.style.display = 'grid'; } }); document.addEventListener('click', function(event) { let elem = document.getElementById('mainProdUpsell'); elem.style.zIndex=2; }); radios = [...document.getElementsByClassName('radios')]; for(let x = 0 ; x < radios.length ;x++){ radios[x].addEventListener('click', function(e){ const form = radios[x].closest('form'); if (form) { const formData = new FormData(form); const productIndex = radios[x].getAttribute("index");; searchInMetafield(formData , productIndex); } }) } closeModals = [...document.getElementsByClassName('close_modal')] for(let x = 0 ; x < closeModals.length ; x++){ closeModals[x].addEventListener('click', function(e){ let parentElement = e.target.parentNode; parentElement.style.display = 'none'; }) } document.querySelectorAll('.upsellCart').forEach(button => { button.addEventListener('mouseover', () => { if (button.disabled) { button.style.cursor = 'not-allowed'; }else{ button.style.cursor = 'pointer'; } }); }); } function handleModalClick(id) { let formattedId = formatIdString(id); let currentButton = document.getElementById(`upsellCartButton${formattedId}`); let currentUpsellProd = document.getElementById(`upsellProd${formattedId}`); let currentModal = document.getElementById(`upsellModal${formattedId}`); let bgColor = getComputedStyle(document.body).backgroundColor; if(currentModal.style.display === 'none' || currentModal.style.display === ''){ currentButton.innerHTML = ` `; currentButton.style.fontsize = '16px'; currentModal.style.display = 'block'; openModals.push(formattedId); }else{ currentModal.style.display = 'none'; currentButton.innerHTML = ` `; openModals = openModals.filter((item) => item != formattedId) } for(let i = 0 ; i < openModals.length ;i++){ let openModalExist = document.getElementById(`upsellModal${openModals[i]}`); let openModalButton = document.getElementById(`upsellCartButton${openModals[i]}`) if(openModalExist && openModals[i] === formattedId){ openModalExist.style.display = 'block'; } else if(openModalExist && openModals[i] != formattedId){ openModalButton.innerHTML = ' '; openModalExist.style.display = 'none'; } } } function formatIdString(id){ let idString = id.toString(); let integerPart = parseInt(idString.split('/').pop()); return integerPart; } function handleButtonClick(id , btn , variant ,index){ let untranslated_variant_title=""; let integerPart = formatIdString(id); let addedVarient = document.getElementById(`addedVarients${index}`); const config = fetchConfig('javascript'); config.headers['X-Requested-With'] = 'XMLHttpRequest'; delete config.headers['Content-Type']; const formData = new FormData(); config.body = formData; formData.append('items[][id]', integerPart); formData.append('items[][quantity]', 1); fetch('/cart/add.js', { method: 'POST', body: formData, headers: { 'X-Requested-With': 'XMLHttpRequest', }, }) .then((response) => response.json()) .then((data) => { if(data.status === 422){ if(btn){ btn.disabled = true; btn.style.cursor = 'not-allowed'; btn.textContent = 'Already Added'; let error = [...document.getElementsByClassName(`error422`)] let currentErrorDiv = error[index]; currentErrorDiv.textContent =`(${data.description.substring(0, 15)}...) are already in your cart.`; currentErrorDiv.style.display = 'block'; setTimeout(()=>{ currentErrorDiv.style.display = 'none'; }, 2000) } }else{ if(btn){ addedVarients.push(parseInt(id)); btn.disabled = true; btn.style.cursor = 'not-allowed'; btn.textContent = 'Added'; untranslated_variant_title = data.items[0].untranslated_variant_title; } addedVarient.innerHTML += `
${untranslated_variant_title}
` } }); } function handleRemoveFromCart(id , varients) { fetch('/cart.js', { method: 'GET', headers: { 'Content-Type': 'application/json', 'X-Requested-With': 'XMLHttpRequest' } }) .then((response) => { if (!response.ok) { throw new Error('Network response was not ok'); } return response.json(); }) .then((cartData) => { const item = cartData.items.find(item => item.id === parseInt(id)); if (item) { const newQuantity = item.quantity - 1; const formData = new FormData(); if (newQuantity +` btn.style.backgroundColor='#fff' prod.style.backgroundColor='#fff' btn.onclick = function() { handleButtonClickNormal(`gid://shopify/ProductVariant/${id}`) }; } } }) .catch((error) => { console.error('Error:', error); }); } function handleButtonClickNormal(id){ let integerPart = formatIdString(id); const btn = document.getElementById(`btnNormal${integerPart}`) const prod = document.getElementById(`upsellProd${integerPart}`) const config = fetchConfig('javascript'); config.headers['X-Requested-With'] = 'XMLHttpRequest'; delete config.headers['Content-Type']; const formData = new FormData(); config.body = formData; formData.append('items[][id]', integerPart); formData.append('items[][quantity]', 1); fetch('/cart/add.js', { method: 'POST', body: formData, headers: { 'X-Requested-With': 'XMLHttpRequest', }, }) .then((response) => response.json()) .then((data) => { if(data.status != 422){ if(btn){ btn.innerHTML = ' '; prod.style.backgroundColor='#e4fee2'; btn.style.backgroundColor='#e4fee2'; btn.onclick = function() { handleRemoveFromCart(integerPart, true); }; } }else{ let error = document.getElementById(`error${integerPart}`) error.textContent =`(${data.description.substring(0, 15)}...) are already in your cart.`; error.style.display = 'block'; setTimeout(()=>{ error.style.display = 'none'; }, 2000) } }); } function searchInMetafield(formData , productIndex){ let string = ""; let variants = products[productIndex].variants.edges; let formDataArray = Array.from(formData.entries()); varaintSubmit = [...document.getElementsByClassName('submitVaraint')]; let btn; for(let i = 0 ; varaintSubmit.length ; i++){ let index = varaintSubmit[i].getAttribute("index"); if(index === productIndex){ btn = varaintSubmit[i]; break; } } for (let i = 0; i < formDataArray.length; i++) { string += `${formDataArray[i][1]}`; if (i !== formDataArray.length - 1) { string += ' / '; } } for (let i = 0; i < variants.length; i++) { let variant = variants[i].node; if (variant.title === string) { let img = document.getElementById(`modalImage${productIndex}`); if (variant.image != null) { img.src = variant.image.url; }else { if (products[productIndex].featuredImage != null) { img.src = products[productIndex].featuredImage.url; }else { img.src = ""; } } if (variant.price != null) { let price = document.getElementById(`modalPrice${productIndex}`); let priceMobile = document.getElementById(`modalPriceMobile${productIndex}`); let str = `${symbol} ${priceRoundingExists && priceRounding === 'enabled' ? roundToNearestMultiple(variant.price*currencyRate , roundingFactor) : (variant.price*currencyRate).toFixed(2)}` price.innerHTML = str; priceMobile.innerHTML = str; } // if(variant.compareAtPrice != null){ // let comaprePrice = document.getElementById(`modalComparePrice${productIndex}`); // let comaprePriceMobile = document.getElementById(`modalComparePriceMobile${productIndex}`); // let condition = variant.compareAtPrice != null && priceRoundingExists && priceRounding === 'enabled' && roundToNearestMultiple(variant.compareAtPrice*currencyRate , roundingFactor) > parseInt(roundToNearestMultiple(variant.price , roundingFactor)); // if(condition){ // comaprePrice.style.display= 'block'; // comaprePriceMobile.style.display= 'block'; // comaprePrice.innerHTML = `${symbol} ${priceRoundingExists && priceRounding === 'enabled' ? roundToNearestMultiple(variant.compareAtPrice*currencyRate , roundingFactor) : (variant.compareAtPrice*currencyRate).toFixed(2)}` // comaprePriceMobile.innerHTML = `${symbol} ${priceRoundingExists && priceRounding === 'enabled' ? roundToNearestMultiple(variant.compareAtPrice*currencyRate , roundingFactor) : (variant.compareAtPrice*currencyRate).toFixed(2)}` // }else{ // comaprePrice.style.display= 'none'; // comaprePriceMobile.style.display= 'none'; // } // } if(!addedVarients.includes(formatIdString(variant.id))){ if (variant.inventoryQuantity
Go to full site