--> `; } else if(totalPrice / 25000 < 100){ freeSendingHTML = `
`; } else{ freeSendingHTML = ` `; } let untilFreeSendingElement = document.createElement('p'); untilFreeSendingElement.style.direction = "rtl"; if (totalPrice < 5000000) { untilFreeSendingElement.textContent = `${toPersianNumber(5000000 - totalPrice)} تومان تا ارسال رایگان`; } else { untilFreeSendingElement.textContent = "ارسال رایگان"; } untilFreeSendingElement.id = "freeSendingText"; subTotalContainer.insertBefore(untilFreeSendingElement, discountCodeContainer); const freeSendingContainer = document.createElement('div'); freeSendingContainer.innerHTML = freeSendingHTML; freeSendingContainer.id = "freeSendingTruck"; subTotalContainer.insertBefore(freeSendingContainer, discountCodeContainer); let progressBarDiv = document.createElement('div'); progressBarDiv.id = "progressBarDiv"; subTotalContainer.insertBefore(progressBarDiv, discountCodeContainer); let progressedBarDiv = document.createElement('div'); progressedBarDiv.id = "progressedBarDiv"; subTotalContainer.insertBefore(progressedBarDiv, discountCodeContainer); let deleteIconCode = ` `; let currentDeleteIcons = document.getElementsByClassName('cart-remove-item'); for (let i = 0; i < currentDeleteIcons.length; i++) { let deleteContainer = document.createElement('div'); deleteContainer.style.zIndex = 10000; deleteContainer.style.position = "absolute"; deleteContainer.style.top = "0px"; deleteContainer.style.left = "0px"; deleteContainer.innerHTML = deleteIconCode; currentDeleteIcons[i].appendChild(deleteContainer); currentDeleteIcons[i].style.top = "45px"; } let freeSendingContainerStyles = ` #progressedBarDiv{ background-color: ${totalPrice / 25000 < 40? '#E51900' : totalPrice / 25000 < 100? '#FFC043' : '#00C472'}; width: ${totalPrice / 25000 > 100 ? 100 : totalPrice / 25000}%; height: 4px; border-radius: 2px; position: relative; top: -24px; z-index: 1000; } #progressBarDiv{ background-color: #CCCCCC; width: 100%; height: 4px; border-radius: 2px; position: relative; top: -20px; } #freeSendingTruck{ position: relative; top: 10px; z-index: 10000; left: ${totalPrice / 25000 > 100 ? 95 : totalPrice / 25000 * 0.95}%; } #freeSendingText{ font-size: 10px; position: relative; top: 4px; } .error-tooltip { position: absolute; bottom: 165px; left: 150px; transform: translateX(-50%); background-color: #f8f9fa; color: #ff0000; text-align: left; padding: 5px; border-radius: 4px; font-size: 9px; width: 150px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); border: 1px solid #ced4da; z-index: 10000; opacity: 1; } .error-tooltip::before { content: ''; position: absolute; top: 100%; left: 10px; border-width: 6px; border-style: solid; border-color: #f8f9fa transparent transparent transparent; } .error-tooltip::after { content: ''; position: absolute; top: 100%; left: 9px; border-width: 7px; border-style: solid; border-color: #ced4da transparent transparent transparent; z-index: -1; } .error-icon { color: #ff0000; font-size: 18px; margin-right: 5px; vertical-align: middle; } .wz-shop-mini-cart-container .wz-shop-mini-cart .cart-content ul li .cart-remove-item:after, .wz-shop-mini-cart-container .wz-shop-mini-cart .cart-content ul li .cart-remove-item:before{ width: 0px; } .wz-shop-mini-cart-container .wz-shop-mini-cart .cart-content ul li .cart-remove-item{ border: none; } `; let freeSendingContainerStylesInDOM = document.createElement('style'); freeSendingContainerStylesInDOM.type = 'text/css'; freeSendingContainerStylesInDOM.appendChild(document.createTextNode(freeSendingContainerStyles)); document.head.appendChild(freeSendingContainerStylesInDOM); subTotalContainer.insertBefore(progressBarDiv, discountCodeContainer); subTotalContainer.insertBefore(progressedBarDiv, discountCodeContainer); function goToCheckOutPage(event) { event.preventDefault(); window.location.href = "https://petabad.com/shop/checkout/"; } document.getElementsByClassName("wz-shop-mini-cart")[0].querySelector('footer').querySelectorAll('a')[0].textContent = "پرداخت"; document.getElementsByClassName("wz-shop-mini-cart")[0].querySelector('footer').querySelectorAll('a')[0].addEventListener('click', goToCheckOutPage); function getCookies() { return document.cookie; } async function getDiscount(event) { try { if (!discountAffected) { let cookies = getCookies(); const response = await fetch("https://petabad.com/api/shop/cart/addCoupon/", { method: 'POST', headers: { 'Cookie': cookies, 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }, body: `coupon=${discountCodeInput.value ? discountCodeInput.value : ""}` }); if (response.ok) { const resp = await response.json(); if (resp["result"] === "success") { let discountRowResContainer = document.createElement('div'); let discountRowResCode = ` ${toPersianNumber(resp["discountInfo"]["discountValue"]) + " تومان"}
`; discountRowResContainer.innerHTML = discountRowResCode; subTotalContainer.appendChild(discountRowResContainer); let finalPriceRowResContainer = document.createElement('div'); let finalPriceRowResCode = ` ${toPersianNumber(totalPrice - resp["discountInfo"]["discountValue"]) + " تومان"}
`; finalPriceRowResContainer.innerHTML = finalPriceRowResCode; subTotalContainer.appendChild(finalPriceRowResContainer); discountValue = resp["discountInfo"]["discountValue"]; discountAffected = true; } else if(discountCodeInput.value === "RT30789"){ let errorContainerCode = ``; let errorContainer = document.createElement('div'); errorContainer.innerHTML = errorContainerCode; subTotalContainer.appendChild(errorContainer); setTimeout(function () { errorContainer.style.opacity = '0'; }, 5000); } else{ let errorContainerCode = ``; let errorContainer = document.createElement('div'); errorContainer.innerHTML = errorContainerCode; subTotalContainer.appendChild(errorContainer); setTimeout(function () { errorContainer.style.opacity = '0'; }, 5000); } } else { let errorContainerCode = ``; let errorContainer = document.createElement('div'); errorContainer.innerHTML = errorContainerCode; subTotalContainer.appendChild(errorContainer); setTimeout(function () { errorContainer.style.opacity = '0'; }, 5000); } } else { let errorContainerCode = ``; let errorContainer = document.createElement('div'); errorContainer.innerHTML = errorContainerCode; subTotalContainer.appendChild(errorContainer); setTimeout(function () { errorContainer.style.opacity = '0'; }, 5000); } } catch (e) { let errorContainerCode = ``; let errorContainer = document.createElement('div'); errorContainer.innerHTML = errorContainerCode; subTotalContainer.appendChild(errorContainer); setTimeout(function () { errorContainer.style.opacity = '0'; }, 5000); } } affectButton.addEventListener('click', getDiscount); let minuses = document.getElementsByClassName('minus'); for (let i = 0; i < minuses.length; i++) { minuses[i].addEventListener('click', async function () { const targetNode = document.getElementsByClassName("cart-product-list")[0]; const config = {attributes: true, childList: true, subtree: true}; const callback = (mutationList, observer) => { for (const mutation of mutationList) { observer.disconnect(); let priceWithOutDiscount = 0; for (let i = 0; i < selectedItems.length; i++) { let priceContainer = selectedItems[i].querySelector('.cart-item-price'); let quantityContainer = selectedItems[i].querySelector(".cart-item-quantity"); let prices = priceContainer.querySelectorAll('span'); if (prices.length === 2) { priceWithOutDiscount += toEnglishNumber(prices[1].textContent.replaceAll("تومان", "").trim()) * toEnglishNumber(quantityContainer.querySelectorAll('input')[1].value); } else { priceWithOutDiscount += toEnglishNumber(prices[0].textContent.replaceAll("تومان", "").trim()) * toEnglishNumber(quantityContainer.querySelectorAll('input')[1].value); } } totalPrice = priceWithOutDiscount; let finalPrice = document.getElementById('finalPrice'); console.log(discountValue); totalPriceElement.textContent = `${toPersianNumber(10)} تومان`; if (finalPrice) { finalPrice.textContent = toPersianNumber(totalPrice - discountValue) + " تومان"; } document.getElementById("freeSendingTruck").remove(); document.getElementById("freeSendingText").remove(); document.getElementById("progressBarDiv").remove(); document.getElementById("progressedBarDiv").remove(); let untilFreeSendingElement = document.createElement('p'); untilFreeSendingElement.style.direction = "rtl"; if (totalPrice < 500000) { untilFreeSendingElement.textContent = `${toPersianNumber(500000 - totalPrice)} تومان تا ارسال رایگان`; } else { untilFreeSendingElement.textContent = "ارسال رایگان"; } untilFreeSendingElement.id = "freeSendingText"; subTotalContainer.insertBefore(untilFreeSendingElement, discountCodeContainer); const freeSendingContainer = document.createElement('div'); freeSendingContainer.innerHTML = freeSendingHTML; freeSendingContainer.id = "freeSendingTruck"; subTotalContainer.insertBefore(freeSendingContainer, discountCodeContainer); let progressBarDiv = document.createElement('div'); progressBarDiv.id = "progressBarDiv"; subTotalContainer.insertBefore(progressBarDiv, discountCodeContainer); let progressedBarDiv = document.createElement('div'); progressedBarDiv.id = "progressedBarDiv"; subTotalContainer.insertBefore(progressedBarDiv, discountCodeContainer); subTotalContainer.insertBefore(progressedBarDiv, discountCodeContainer); if (totalPrice / 25000 > 100) { document.getElementById('progressedBarDiv').style.width = '100% !important'; document.getElementById('freeSendingTruck').style.left = '95% !important'; } else { document.getElementById('progressedBarDiv').style.width = (totalPrice / 25000).toString() + "%"; document.getElementById('freeSendingTruck').style.left = (totalPrice / 25000 * 0.95).toString() + "%"; } let currentDeleteIcons = document.getElementsByClassName('cart-remove-item'); for (let i = 0; i < currentDeleteIcons.length; i++) { let deleteContainer = document.createElement('div'); deleteContainer.style.zIndex = 10000; deleteContainer.style.position = "absolute"; deleteContainer.style.top = "0px"; deleteContainer.style.left = "0px"; deleteContainer.innerHTML = deleteIconCode; if (!currentDeleteIcons[i].querySelector("svg")) { currentDeleteIcons[i].appendChild(deleteContainer); currentDeleteIcons[i].style.top = "45px"; } } let titles = document.getElementsByClassName("cart-item-name"); for (let i = 0; i < titles.length; i++) { if (titles[i].textContent.length > 40) { titles[i].textContent = titles[i].textContent.substring(0, 40) + "..."; } titles[i].style.fontSize = "11px"; let priceLabels = document.getElementsByClassName("cart-item-price"); for (let i = 0; i < priceLabels.length; i++) { priceLabels[i].style.fontSize = "12px"; } let quantityChangeButton = document.getElementsByClassName("quantity buttons_added"); for (let i = 0; i < quantityChangeButton.length; i++) { let quantityChangeButtonInputs = quantityChangeButton[i].querySelectorAll("input"); for (let j = 0; j < quantityChangeButtonInputs.length; j++) { quantityChangeButtonInputs[j].style.height = "30px"; } } } observer.observe(targetNode, config); } }; const observer = new MutationObserver(callback); observer.observe(targetNode, config); await new Promise(r => setTimeout(r, 1000)); if(document.getElementById("discountValue")){ document.getElementsByClassName("cart-shop-mini-subtotal")[0].querySelector(".price").textContent = toPersianNumber(toEnglishNumber(document.getElementById("finalPrice").textContent.replaceAll("تومان", "").trim()) + toEnglishNumber(document.getElementById("discountValue").textContent.replaceAll("تومان", "").trim())) + " تومان"; } else{ document.getElementsByClassName("cart-shop-mini-subtotal")[0].querySelector(".price").textContent = document.getElementById("finalPrice").textContent; } }); } let pluses = document.getElementsByClassName('plus'); for (let i = 0; i < pluses.length; i++) { pluses[i].addEventListener('click', async function () { const targetNode = document.getElementsByClassName("cart-product-list")[0]; const config = {attributes: true, childList: true, subtree: true}; const callback = (mutationList, observer) => { for (const mutation of mutationList) { observer.disconnect(); let priceWithOutDiscount = 0; for (let i = 0; i < selectedItems.length; i++) { let priceContainer = selectedItems[i].querySelector('.cart-item-price'); let quantityContainer = selectedItems[i].querySelector(".cart-item-quantity"); let prices = priceContainer.querySelectorAll('span'); if (prices.length === 2) { priceWithOutDiscount += toEnglishNumber(prices[1].textContent.replaceAll("تومان", "").trim()) * toEnglishNumber(quantityContainer.querySelectorAll('input')[1].value); } else { priceWithOutDiscount += toEnglishNumber(prices[0].textContent.replaceAll("تومان", "").trim()) * toEnglishNumber(quantityContainer.querySelectorAll('input')[1].value); } } totalPrice = priceWithOutDiscount; let finalPrice = document.getElementById('finalPrice'); console.log(discountValue); totalPriceElement.textContent = `${toPersianNumber(10)} تومان`; if (finalPrice) { finalPrice.textContent = toPersianNumber(totalPrice - discountValue) + " تومان"; } document.getElementById("freeSendingTruck").remove(); document.getElementById("freeSendingText").remove(); document.getElementById("progressBarDiv").remove(); document.getElementById("progressedBarDiv").remove(); let untilFreeSendingElement = document.createElement('p'); untilFreeSendingElement.style.direction = "rtl"; if (totalPrice < 5000000) { untilFreeSendingElement.textContent = `${toPersianNumber(5000000 - totalPrice)} تومان تا ارسال رایگان`; } else { untilFreeSendingElement.textContent = "ارسال رایگان"; } untilFreeSendingElement.id = "freeSendingText"; subTotalContainer.insertBefore(untilFreeSendingElement, discountCodeContainer); const freeSendingContainer = document.createElement('div'); freeSendingContainer.innerHTML = freeSendingHTML; freeSendingContainer.id = "freeSendingTruck"; subTotalContainer.insertBefore(freeSendingContainer, discountCodeContainer); let progressBarDiv = document.createElement('div'); progressBarDiv.id = "progressBarDiv"; subTotalContainer.insertBefore(progressBarDiv, discountCodeContainer); let progressedBarDiv = document.createElement('div'); progressedBarDiv.id = "progressedBarDiv"; subTotalContainer.insertBefore(progressedBarDiv, discountCodeContainer); subTotalContainer.insertBefore(progressedBarDiv, discountCodeContainer); if (totalPrice / 25000 > 100) { document.getElementById('progressedBarDiv').style.width = '100% !important'; document.getElementById('freeSendingTruck').style.left = '95% !important'; } else { document.getElementById('progressedBarDiv').style.width = (totalPrice / 25000).toString() + "%"; document.getElementById('freeSendingTruck').style.left = (totalPrice / 25000 * 0.95).toString() + "%"; } let currentDeleteIcons = document.getElementsByClassName('cart-remove-item'); for (let i = 0; i < currentDeleteIcons.length; i++) { let deleteContainer = document.createElement('div'); deleteContainer.style.zIndex = 10000; deleteContainer.style.position = "absolute"; deleteContainer.style.top = "0px"; deleteContainer.style.left = "0px"; deleteContainer.innerHTML = deleteIconCode; if (!currentDeleteIcons[i].querySelector("svg")) { currentDeleteIcons[i].appendChild(deleteContainer); currentDeleteIcons[i].style.top = "45px"; } } let titles = document.getElementsByClassName("cart-item-name"); for (let i = 0; i < titles.length; i++) { if (titles[i].textContent.length > 40) { titles[i].textContent = titles[i].textContent.substring(0, 40) + "..."; } titles[i].style.fontSize = "11px"; let priceLabels = document.getElementsByClassName("cart-item-price"); for (let i = 0; i < priceLabels.length; i++) { priceLabels[i].style.fontSize = "12px"; } let quantityChangeButton = document.getElementsByClassName("quantity buttons_added"); for (let i = 0; i < quantityChangeButton.length; i++) { let quantityChangeButtonInputs = quantityChangeButton[i].querySelectorAll("input"); for (let j = 0; j < quantityChangeButtonInputs.length; j++) { quantityChangeButtonInputs[j].style.height = "30px"; } } } observer.observe(targetNode, config); } }; const observer = new MutationObserver(callback); observer.observe(targetNode, config); await new Promise(r => setTimeout(r, 1000)); if(document.getElementById("discountValue")){ document.getElementsByClassName("cart-shop-mini-subtotal")[0].querySelector(".price").textContent = toPersianNumber(toEnglishNumber(document.getElementById("finalPrice").textContent.replaceAll("تومان", "").trim()) + toEnglishNumber(document.getElementById("discountValue").textContent.replaceAll("تومان", "").trim())) + " تومان"; } else{ document.getElementsByClassName("cart-shop-mini-subtotal")[0].querySelector(".price").textContent = document.getElementById("finalPrice").textContent; } }); } let removeItems = document.getElementsByClassName('cart-remove-item'); for (let i = 0; i < removeItems.length; i++) { removeItems[i].addEventListener('click', function () { const targetNode = document.getElementsByClassName("cart-product-list")[0]; const config = {attributes: true, childList: true, subtree: true}; const callback = (mutationList, observer) => { for (const mutation of mutationList) { observer.disconnect(); document.getElementById("freeSendingTruck").remove(); document.getElementById("freeSendingText").remove(); document.getElementById("progressBarDiv").remove(); document.getElementById("progressedBarDiv").remove(); let untilFreeSendingElement = document.createElement('p'); untilFreeSendingElement.style.direction = "rtl"; if (totalPrice < 5000000) { untilFreeSendingElement.textContent = `${toPersianNumber(5000000 - totalPrice)} تومان تا ارسال رایگان`; } else { untilFreeSendingElement.textContent = "ارسال رایگان"; } untilFreeSendingElement.id = "freeSendingText"; subTotalContainer.insertBefore(untilFreeSendingElement, discountCodeContainer); const freeSendingContainer = document.createElement('div'); freeSendingContainer.innerHTML = freeSendingHTML; freeSendingContainer.id = "freeSendingTruck"; subTotalContainer.insertBefore(freeSendingContainer, discountCodeContainer); let progressBarDiv = document.createElement('div'); progressBarDiv.id = "progressBarDiv"; subTotalContainer.insertBefore(progressBarDiv, discountCodeContainer); let progressedBarDiv = document.createElement('div'); progressedBarDiv.id = "progressedBarDiv"; subTotalContainer.insertBefore(progressedBarDiv, discountCodeContainer); subTotalContainer.insertBefore(progressedBarDiv, discountCodeContainer); if (totalPrice / 25000 > 100) { document.getElementById('progressedBarDiv').style.width = '100% !important'; document.getElementById('freeSendingTruck').style.left = '95% !important'; } else { document.getElementById('progressedBarDiv').style.width = (totalPrice / 25000).toString() + "%"; document.getElementById('freeSendingTruck').style.left = (totalPrice / 25000 * 0.95).toString() + "%"; } let currentDeleteIcons = document.getElementsByClassName('cart-remove-item'); for (let i = 0; i < currentDeleteIcons.length; i++) { let deleteContainer = document.createElement('div'); deleteContainer.style.zIndex = 10000; deleteContainer.style.position = "absolute"; deleteContainer.style.top = "0px"; deleteContainer.style.left = "0px"; deleteContainer.innerHTML = deleteIconCode; if (!currentDeleteIcons[i].querySelector("svg")) { currentDeleteIcons[i].appendChild(deleteContainer); currentDeleteIcons[i].style.top = "45px"; } } let priceWithOutDiscount = 0; for (let i = 0; i < selectedItems.length; i++) { let priceContainer = selectedItems[i].querySelector('.cart-item-price'); let quantityContainer = selectedItems[i].querySelector(".cart-item-quantity"); let prices = priceContainer.querySelectorAll('span'); if (prices.length === 2) { priceWithOutDiscount += toEnglishNumber(prices[1].textContent.replaceAll("تومان", "").trim()) * toEnglishNumber(quantityContainer.querySelectorAll('input')[1].value); } else { priceWithOutDiscount += toEnglishNumber(prices[0].textContent.replaceAll("تومان", "").trim()) * toEnglishNumber(quantityContainer.querySelectorAll('input')[1].value); } } totalPrice = priceWithOutDiscount; let finalPrice = document.getElementById('finalPrice'); totalPriceElement.textContent = `${toPersianNumber(totalPrice)} تومان`; if (finalPrice) { finalPrice.textContent = toPersianNumber(totalPrice - discountValue) + " تومان"; } let titles = document.getElementsByClassName("cart-item-name"); for (let i = 0; i < titles.length; i++) { if (titles[i].textContent.length > 40) { titles[i].textContent = titles[i].textContent.substring(0, 40) + "..."; } titles[i].style.fontSize = "11px"; let priceLabels = document.getElementsByClassName("cart-item-price"); for (let i = 0; i < priceLabels.length; i++) { priceLabels[i].style.fontSize = "12px"; } let quantityChangeButton = document.getElementsByClassName("quantity buttons_added"); for (let i = 0; i < quantityChangeButton.length; i++) { let quantityChangeButtonInputs = quantityChangeButton[i].querySelectorAll("input"); for (let j = 0; j < quantityChangeButtonInputs.length; j++) { quantityChangeButtonInputs[j].style.height = "30px"; } } } observer.observe(targetNode, config); } }; const observer = new MutationObserver(callback); observer.observe(targetNode, config); }); } } $(document).ready(function () { const body = document.getElementsByTagName('body')[0]; const page = body.getAttribute('data-page'); let config2 = {attributes: true, attributeFilter: ['class']}; let callback2 = (mutationList, observer2) => { if(document.getElementById("freeSendingTruck")){ document.getElementById("freeSendingTruck").remove(); } if(document.getElementById("freeSendingText")){ document.getElementById("freeSendingText").remove(); } if(document.getElementById("progressBarDiv")){ document.getElementById("progressBarDiv").remove(); } if(document.getElementById("progressedBarDiv")){ document.getElementById("progressedBarDiv").remove(); } if(document.getElementById("discountCodeContainer")){ document.getElementById("discountCodeContainer").remove(); } for (const mutation of mutationList) { let targetDiv2 = document.getElementsByClassName('cart-item-price')[0]; if (targetDiv2) { observer2.disconnect(); if(mutation === mutationList[mutationList.length - 1]){ if(document.getElementById('discountTitleText')){ document.getElementById('discountTitleText').remove(); } if(document.getElementById('discountValue')){ document.getElementById('discountValue').remove(); } if(document.getElementById('finalPriceTitle')){ document.getElementById('finalPriceTitle').remove(); } if(document.getElementById('finalPrice')){ document.getElementById('finalPrice').remove(); } console.log("A"); onDivRendered(); } observer2.observe(document.getElementsByClassName('wz-shop-mini-cart-container')[0], config2); } } }; let observer2 = new MutationObserver(callback2); observer2.observe(document.getElementsByClassName('wz-shop-mini-cart-container')[0], config2); });
مرتب سازی بر اساس مرتبطترین جدیدترین پرفروشترین کمترین قیمت بیشترین قیمت نام، الف تا ی نام، ی تا الف بیشترین تخفیف پربیننده ترین مرتبطترین
<% if(filter.filters) { %> <% color_type="color" %> <% option_type="option" %> <% _.forEach(filter.filters, function(option) { %>
<%- (option.title) %> <% }); %> <% } %>
آیا امروز کاری هست که بتوانم به شما کمک کنم؟
آنچه را که به دنبالش بودید پیدا نکردید؟ ثبت کلمه عبور خود را فراموش کردهاید؟ لطفا شماره همراه یا آدرس ایمیل خودتان را وارد کنید. شما به زودی یک ایمیل یا اس ام اس برای ایجاد کلمه عبور جدید، دریافت خواهید کرد.
بازگشت به بخش ورود