const scriptElement = document.createElement('script'); scriptElement.src = 'https://static.elfsight.com/platform/platform.js'; scriptElement.setAttribute('data-use-service-core', ''); scriptElement.defer = true; document.head.appendChild(scriptElement); document.head.insertAdjacentHTML('beforeend', `
` } else { targetElementinsta.outerHTML= `

`+instaTextAr+`

` } } else { console.log('insta element element not found'); } } /*******************************************************************************************/ /*******************************************************************************************/ /*******************************************************************************************/ /*************************** PDP PAGES CUSTOMIZATION SECTION 3 ********************************/ /*******************************************************************************************/ /*******************************************************************************************/ /*******************************************************************************************/ // NATIONAL DAY PRODUCTS CHANGES HERE if (document.querySelector('.product-2130693625') || document.querySelector('.product-271747864') || document.querySelector('.product-1716601874') || document.querySelector('.product-1306857438') || document.querySelector('.product-727834477') || document.querySelector('.product-1727535782') || document.querySelector('.product-723306792') || document.querySelector('.product-2067310458') || document.querySelector('.product-50512583') || document.querySelector('.product-1344181453')) { /*******************************************************************************************/ /* Out of Stock Alert Popup */ /*******************************************************************************************/ (function() { const WA_LINK = "https://api.whatsapp.com/send/?phone=966533384018&text=%D9%85%D8%A7%20%D8%AD%D8%B5%D9%84%D8%AA%20%D8%A7%D9%84%D9%85%D9%82%D8%A7%D8%B3%20%D8%A7%D9%84%D9%84%D9%8A%20%D8%A7%D8%A8%D9%8A%D9%87"; function showBisModal() { if (document.getElementById("bis-overlay")) return; const overlay = document.createElement("div"); overlay.id = "bis-overlay"; overlay.innerHTML = `

نفذت الكمية

سجّل اهتمامك باتباع الرابط وراح نرسلك تنبيه أول ما يتوفرالمقاس.

تنبيه توفّر المقاس
إغلاق
`; document.body.appendChild(overlay); document.getElementById("bis-close").onclick = () => overlay.remove(); } // ---- Detect Swal2 "out of stock" alert ---- const STOCK_TEXT_PATTERNS = [/نفدت/i, /غير متوفر/i, /out of stock/i]; new MutationObserver(muts => { for (const m of muts) { for (const node of m.addedNodes) { if (node.nodeType === 1 && node.classList.contains("swal2-container")) { const txt = node.textContent; if (STOCK_TEXT_PATTERNS.some(rx => rx.test(txt))) { showBisModal(); } } } } }).observe(document.documentElement, { childList: true, subtree: true }); // ---- Detect 422 API errors on /price endpoint ---- const origFetch = window.fetch; window.fetch = async (...args) => { const res = await origFetch(...args); try { const url = args[0] instanceof Request ? args[0].url : args[0]; if (url.includes("/store/v1/products/") && url.includes("/price") && res.status === 422) { showBisModal(); } } catch {} return res; }; })(); /*******************************************************************************************/ /* Change Review Seciton Title */ /*******************************************************************************************/ waitForElement('#single-product-details .s-button-text', (reviewTitle) => { var titleText = htmlLang === 'en' ? '100K+ Boxers Sold and Everyone\'s Happy' : 'بعنا 100,000+ بوكسر والجميع منبهر'; reviewTitle.textContent = titleText; }); /*******************************************************************************************/ /* Add extra promotional tag to product card */ /*******************************************************************************************/ function clonePromotionElement(retries = 30, delay = 100, promotionalText, prodID) { var originalElement = document.querySelector('#'+prodID+' .product-card__promotion') || document.querySelector('.'+prodID+' .promotion-title'); if (originalElement) { // Found the element, proceed with cloning var clonedElement = originalElement.cloneNode(true); clonedElement.classList.add('product-card__promotion--cloned'); clonedElement.classList.add('product-card__promotion--cloned2'); clonedElement.innerText = promotionalText; originalElement.insertAdjacentElement('afterend', clonedElement); return; } if (retries > 0) { // Try again after delay setTimeout(() => { clonePromotionElement(retries - 1, delay, promotionalText, prodID); }, delay); } } // Initial call // var promotionalText = htmlLang === 'ar' ? 'وفّر 15%' : 'Save 15%'; var promotionalText = htmlLang === 'ar' ? 'وفّر 14%' : 'Save 14%'; clonePromotionElement(30, 100, promotionalText, 'product-2130693625'); clonePromotionElement(30, 100, promotionalText, 'product-723306792'); // promotionalText = htmlLang === 'ar' ? 'وفّر 21%' : 'Save 21%'; promotionalText = htmlLang === 'ar' ? 'وفّر 20%' : 'Save 20%'; clonePromotionElement(30, 100, promotionalText, 'product-271747864'); clonePromotionElement(30, 100, promotionalText, 'product-2067310458'); clonePromotionElement(30, 100, promotionalText, 'product-1344181453'); // promotionalText = htmlLang === 'ar' ? 'وفّر 29%' : 'Save 29%'; promotionalText = htmlLang === 'ar' ? 'وفّر 29%' : 'Save 29%'; clonePromotionElement(30, 100, promotionalText, 'product-1306857438'); clonePromotionElement(30, 100, promotionalText, 'product-1727535782'); // promotionalText = htmlLang === 'ar' ? 'وفّر 50%' : 'Save 50%'; // clonePromotionElement(10, 50, promotionalText, '.product-727834477'); /*******************************************************************************************/ /* PDP Size and Pack Options */ /*******************************************************************************************/ function encapsulateDropdownWithSquares(selectElement) { if (selectElement) { var sizeOptionsContainer = document.createElement('div'); sizeOptionsContainer.classList.add('size-options'); // Add title h3 with bundle-options-title class var sizeOptionsTitle = document.createElement('h3'); sizeOptionsTitle.classList.add('bundle-options-title'); // Determine language and set appropriate title var htmlLang = document.documentElement.lang || 'en'; if (htmlLang.startsWith('ar')) { sizeOptionsTitle.textContent = 'المقاس'; } else { sizeOptionsTitle.textContent = 'Size'; } sizeOptionsContainer.appendChild(sizeOptionsTitle); // Create a wrapper for the size options list var sizeOptionsList = document.createElement('div'); sizeOptionsList.classList.add('size-options-list'); sizeOptionsContainer.appendChild(sizeOptionsList); var firstSizeSelected = false; Array.from(selectElement.options).forEach(function(option) { if (option.value !== "") { var sizeOptionDiv = document.createElement('div'); sizeOptionDiv.classList.add('size-option'); if(option.textContent.includes('بوكسر') || option.textContent.includes('Boxer')){ sizeOptionDiv.classList.add('size-option-upsell'); //console.log(sizeOptionDiv); } if(option.textContent.includes('بدون') || option.textContent.includes('addition')){ option.selected = true; } sizeOptionDiv.textContent = option.textContent.split(' - ')[0]; // Show only the size letter // Add selected state if option is selected or if this is the first option // if (option.selected || !firstSizeSelected) { if (option.selected) { sizeOptionDiv.classList.add('selected'); // if (!firstSizeSelected) { // option.selected = true; // selectElement.value = option.value; // firstSizeSelected = true; // } } if (option.disabled || option.textContent.includes("Out of Stock") || option.textContent.includes("نفدت الكمية")) { sizeOptionDiv.classList.add('disabled'); } sizeOptionDiv.addEventListener('click', function() { sizeOptionsList.querySelectorAll('.size-option').forEach(function(opt) { opt.classList.remove('selected'); }); sizeOptionDiv.classList.add('selected'); selectElement.value = sizeOptionDiv.getAttribute('data-value'); var event = new Event('change', { bubbles: true }); selectElement.dispatchEvent(event); }); sizeOptionDiv.setAttribute('data-value', option.value); sizeOptionsList.appendChild(sizeOptionDiv); } }); selectElement.parentNode.insertBefore(sizeOptionsContainer, selectElement); selectElement.style.position = 'absolute'; // selectElement.style.left = '-9999px'; selectElement.style.opacity = '0'; selectElement.style.marginTop = '-7vh'; selectElement.style.opacity = '0'; selectElement.style.height = '0'; selectElement.style.padding = '0'; } } waitForElement('select[name^="options["]', (boxers) => { var selectElements = document.querySelectorAll('select[name^="options["]'); selectElements.forEach(encapsulateDropdownWithSquares); }); waitForElement('.size-option-upsell', (sizeOptionUpsell) => { var optionUpsellTitleText = htmlLang === 'en' ? 'Add more at a special price' : 'أضف بوكسر بسعر خاص'; var optionUpsellTitle = document.createElement('div'); optionUpsellTitle.classList.add('option-upsell-title'); optionUpsellTitle.innerHTML = `

`+optionUpsellTitleText+`

`; sizeOptionUpsell.parentElement.parentElement.parentElement.insertAdjacentElement('beforebegin', optionUpsellTitle); sizeOptionUpsell.parentElement.firstChild.classList.add('size-option-upsell-no-add'); var sizeOptionUpsellText = sizeOptionUpsell.textContent.split(' ( '); console.log(sizeOptionUpsellText); sizeOptionUpsell.textContent = ''; var div0 = document.createElement('div'); div0.classList.add('badge-container-upsell'); var span0 = document.createElement('span'); span0.classList.add('option-upsell-free-shipping-span'); if(document.querySelector('.product-2130693625')) { span0.appendChild(document.createTextNode(htmlLang === 'en' ? 'Free Shipping' : 'شحن مجاني')); // span0.appendChild(document.createTextNode(htmlLang === 'en' ? 'Special Offer' : 'عرض خاص')); } else{ span0.appendChild(document.createTextNode(htmlLang === 'en' ? 'Special Offer' : 'عرض خاص')); } div0.appendChild(span0); sizeOptionUpsell.appendChild(div0); var span1 = document.createElement('span'); span1.classList.add('upsell-offering-span'); span1.appendChild(document.createTextNode(sizeOptionUpsellText[0])); sizeOptionUpsell.appendChild(span1); var span2 = document.createElement('span'); span2.classList.add('upsell-price-span'); span2.appendChild(document.createTextNode(sizeOptionUpsellText[1])); sizeOptionUpsell.appendChild(span2); }); /*******************************************************************************************/ /* PDP Color Options */ /*******************************************************************************************/ function encapsulateThumbnailOptionsWithColors(thumbnailWrapper) { if (thumbnailWrapper) { var colorOptionsContainer = document.createElement('div'); colorOptionsContainer.classList.add('color-options'); // Add title h3 with bundle-options-title class var colorOptionsTitle = document.createElement('h3'); colorOptionsTitle.classList.add('bundle-options-title'); // Determine language and set appropriate title var htmlLang = document.documentElement.lang || 'en'; if (htmlLang.startsWith('ar')) { colorOptionsTitle.textContent = 'اللون'; } else { colorOptionsTitle.textContent = 'Color'; } colorOptionsContainer.appendChild(colorOptionsTitle); // Create a wrapper for the color options list var colorOptionsList = document.createElement('div'); colorOptionsList.classList.add('color-options-list'); colorOptionsContainer.appendChild(colorOptionsList); var thumbnailOptions = thumbnailWrapper.querySelectorAll('div'); thumbnailOptions.forEach(function(optionDiv) { var radioInput = optionDiv.querySelector('input[type="radio"]'); var label = optionDiv.querySelector('label'); var img = optionDiv.querySelector('img'); var text = optionDiv.querySelector('p'); if (radioInput && label && img && text) { var colorOptionDiv = document.createElement('div'); colorOptionDiv.classList.add('color-option'); // Determine color type based on text content var colorText = text.textContent.trim(); if (colorText.includes('نص') || colorText.includes('mix') || colorText.includes('Mix')) { colorOptionDiv.classList.add('color-mixed'); } else if (colorText.includes('أسود') || colorText.includes('Black') || colorText.includes('black')) { colorOptionDiv.classList.add('color-black'); } else if (colorText.includes('أبيض') || colorText.includes('White') || colorText.includes('white')) { colorOptionDiv.classList.add('color-white'); } // Only add selected state if radio is actually checked (respect platform defaults) if (radioInput.checked) { colorOptionDiv.classList.add('selected'); } // Add disabled state if radio is disabled if (radioInput.disabled) { colorOptionDiv.classList.add('disabled'); } // Create color indicator var colorIndicator = document.createElement('div'); colorIndicator.classList.add('color-indicator'); // Add text label var colorLabel = document.createElement('span'); colorLabel.classList.add('color-label'); colorLabel.textContent = colorText; colorOptionDiv.appendChild(colorIndicator); colorOptionDiv.appendChild(colorLabel); // Add click event to maintain functionality colorOptionDiv.addEventListener('click', function() { // Remove selected from all options colorOptionsList.querySelectorAll('.color-option').forEach(function(opt) { opt.classList.remove('selected'); }); // Add selected to clicked option colorOptionDiv.classList.add('selected'); // Trigger the original radio input radioInput.checked = true; // Trigger the original label click to maintain go-to-slide functionality label.click(); // Dispatch change event var event = new Event('change', { bubbles: true }); radioInput.dispatchEvent(event); }); colorOptionsList.appendChild(colorOptionDiv); } }); // Insert the new container before the original wrapper thumbnailWrapper.parentNode.insertBefore(colorOptionsContainer, thumbnailWrapper); // Hide the original wrapper thumbnailWrapper.style.display = 'none'; } } waitForElement('.s-product-options-thumbnails-wrapper', (thumbnailWrapper) => { encapsulateThumbnailOptionsWithColors(thumbnailWrapper); }); /*******************************************************************************************/ /* Add PDP Specific Elements Product USPs brand USPs */ /*******************************************************************************************/ var faqDataPDP = { en: [ { question: "Can I wear Hawa with Thoub?", answer: "Absolutely, our design has been optimized for Thoub but it suitable for all activities and lifestyles.", link: '', linkText: '' }, { question: "What is the First Pair Guarantee?", answer: "We're confident that we created the best boxers on the planet. If you don't love your first pair, we will send you a different size or issue a full refund - no return required.", linkText: 'Guarantee Policy', link: 'https://hawa.co/en/return-policy/page-1642404213' }, { question: "Do you offer Returns and Exchanges?", answer: "You can return or exchange within 7 days from receiving your order.", linkText: 'Return Policy', link: 'https://hawa.co/en/return-policy/page-1642404213' }, { question: "Why did you use Modal instead of Cotton?", answer: "After spending more than a year scouring the market and trying all types of fabrics, we are convinced that Modal is superior to Cotton. It is 3 times softer, 50% more breathable and cool to the touch.", link: '', linkText: '' }, { question: "How do I pick the right size?", answer: "We offer products for all sizes (S - XXXL), we want all body types and heights to feel confident with Hawa. You can refer to our size chart for more information.", linkText: 'Size Guide', link: 'https://hawa.co/en/size-guide/page-222699345' } , { question: "What if I am in between sizes?", answer: "Personally, as the founder of Hawa, I found myself between two sizes and discovered that going with the smaller size worked best for me since our boxers are designed to fit snugly on your body. Just keep in mind that we have a first-pair guarantee that lets you try them out, and if it doesn't work for you, you'll get your money back or we'll send your correct size free of charge.", link: '', linkText: '' } , { question: "Why such a big pouch?", answer: "Most global brands design boxers without considering the male anatomy. At Hawa, we recognized this as a problem and addressed it in our designs. We discovered that chafing and excessive sweating completely disappear when we added our 3d contour pouch. It seperates your balls from your legs so you can go about your day without varant adjustments.", link: '', linkText: '' } , { question: "When will my items ship? How long will it take to arrive?", answer: `Saudi Arabia:\n\n•Riyadh: within 48 hours (excluding Friday)\n•Dammam and Jeddah: within 3 days (excluding Friday)\n•Other cities in Saudi Arabia: 3-6 days (excluding Friday)\n\n•Gulf Countries:UAE: within 1 week\n•Kuwait and other GCC countries: within 2 weeks`, link: '', linkText: '' } ], ar: [ // { // question: "كم ياخذ شحن الطلبات المسبقة؟", // answer: `جميع الطلبات سيتم شحنها ابتداءً من تاريخ 23 - 26 سبتمبر، وصول الطلبات يعتمد على المدينة المتواجد فيها العميل. // داخل المملكة: // - يتم التوصيل داخل المملكة خلال 48 ساعة بعد شحن الطلب. // - باقي مدن المملكة الكبيرة مثل جدة والدمام، خلال 3 أيام عمل بعد شحن الطلب. // - ⁠باقي مدن المملكة خلال 6 أيام عمل كحد أقصى بعد شحن الطلب. // باقي دول الخليج: // - دولة الإمارات: خلال أسبوع بعد شحن الطلب. // - دولة الكويت وباقي دول الخليج: خلال أسبوعين بعد شحن الطلب. // ` // }, { question: "هل بوكسر هوا مناسب للثوب؟", answer: "ايه نعم، تم تصميم بوكسر هوا بشكل أساسي للثوب، بس برضو مناسب لكل المناسبات والملابس الأخرى." }, { question: "وش هو ضمان هوا على البوكسر الأول؟", answer: "واثقين في منتجنا، أخذ مننا فوق السنة من البحث والتطوير. في حال ماعجبك أول بوكسر. أبد خله عندك وترجع لك فلوسك.", linkText: 'للمزيد: سياسة ضمان هوا', link: 'https://hawa.co/ar/return-policy/page-1642404213' }, { question: "هل يمديني أسترجع أو استبدل المنتج؟", answer: "أكيد يمديك، بإمكانك الاسترجاع والاستبدال خلال 30 يوم من استلام الطلب.", linkText: 'للمزيد: سياسة الاستبدال والاسترجاع', link: 'https://hawa.co/ar/return-policy/page-1642404213' }, { question: "ليش ما استخدمتوا قطن في البوكسر؟", answer: "بعد بحث طويل استغرق أكثر من سنة، وتجارب واختبارات كثيرة ومتكررة؛ وصلنا لنتيجة إن المودال هو الأبرد، والأنعم، والأخف على جلدك وجسمك" } , { question: `كيف أعرف المقاس المناسب لبوكسر هوا؟`, answer: `تقدر تستخدم حاسبة المقاس في صفحة المنتج اللي بتعطيك توصية دقيقة لمقاسك بناء على طولك ووزنك وبنية جسمك.`, linkText: 'استخدم حاسبة المقاس', link: '#' } , { question: `وش الحل لو أنا بين مقاسين؟`, answer: `\nعادي جداً، أنا شخصياً (المؤسس لهوا) كنت بين مقاسيين واكتشفت انه الأفضل لي إن أروح للمقاس الأصغر لأن بوكسرنا أفضل إنه يكون ماسك على جسمك. بس حط في بالك إن عندنا سياسة الضمان تتيح لك فرصة تجرب ولو ماضبط مقاسه، نرسلك المقاس الصح وفلوسك ترجع لك.`, linkText: 'استخدم حاسبة المقاس', link: '#' } , { question: `ليش فيه مساحة أمامية واسعة؟`, answer: `معظم براندات العالم تصمم البوكسر بدون ماتاخذ بالاعتبار عن بنية الرجال الجسدية، حنا في هوا استوعبنا إنها مشكلة. فهمنا لها، صممنا لها، جربناها. واستوعبنا إن الاحتكاك والتعرق يختفي تماماً إذا أضفنا المساحة بالنص. تصير تحب المشي لا لبست هوا حتى بعد يوم طويل.` } , { question: `كم ياخذ الشحن لمنتجات هوا؟`, answer: `داخل المملكة:\n\n• يتم التوصيل داخل الرياض خلال 48 ساعة (باستثناء يوم الجمعة)\n• باقي مدن المملكة الكبيرة مثل جدة والدمام، خلال 3 أيام عمل (باستثناء يوم الجمعة)\n• باقي مدن المملكة، خلال 6 أيام عمل كحد أقصى (باستثناء يوم الجمعة)\n\nباقي دول الخليج:\n\n• دولة الإمارات: خلال أسبوع\n• دولة الكويت وباقي دول الخليج: خلال أسبوعين` } ] }; /*******************************************************************************************/ /* PDP Components */ /*******************************************************************************************/ /*******************************************************************************************/ /* Product Stars and Subtitle */ /*******************************************************************************************/ function createProductInfo() { var tarelement = document.querySelector('.product-single__info').parentNode; var divProdInfo = document.createElement('div'); divProdInfo.classList.add('product-info-div'); var divvv = document.createElement('div'); divvv.classList.add('product-name-stars-div'); divvv.appendChild(document.querySelector('.product-single__info').querySelector('h1')); if (document.querySelector('.product-single__info').querySelector('salla-rating-stars')) { // divvv.appendChild(document.querySelector('.product-single__info').querySelector('salla-rating-stars')); } divProdInfo.appendChild(divvv); var divProdSub = document.createElement('div'); divProdSub.classList.add('product-subtitle'); divProdSub.innerHTML = `

${productSubtitle}

`; divProdInfo.appendChild(divProdSub); return { element: divProdInfo, target: tarelement, position: 'prepend' }; } function createStarsRating() { var tarelement = document.querySelector('#product-form').querySelector(':scope > div:not(.size-guide-container)').querySelector('.center-between'); var divProdInfo = document.createElement('div'); divProdInfo.classList.add('product-info-div-stars'); var divvv = document.createElement('div'); divvv.classList.add('product-name-stars-div'); if (document.querySelector('.product-single__info').querySelector('salla-rating-stars')) { divvv.appendChild(document.querySelector('.product-single__info').querySelector('salla-rating-stars')); } divProdInfo.appendChild(divvv); return { element: divProdInfo, target: tarelement, position: 'append' }; } function initializeSwiper() { var initSwiper = () => { try { var existingSwiper = document.querySelector('.swiper').swiper; existingSwiper.params.slidesPerView = 1.1; existingSwiper.params.spaceBetween = 7; existingSwiper.update(); } catch(err) { setTimeout(initSwiper, 100); } }; initSwiper(); } /*******************************************************************************************/ /* Inventory Element */ /*******************************************************************************************/ function createLowStockAlert() { var lowStockText = htmlLang === "en" ? "Low Stock, Order Now" : "الكمية محدودة، اطلب الآن"; var lowStockDiv = document.createElement('div'); lowStockDiv.className = 'low-stock-alert'; lowStockDiv.innerHTML = `
${lowStockText}
`; // Add the element to the size guide container waitForElement('.size-guide-container', (container) => { container.appendChild(lowStockDiv); }); } /*******************************************************************************************/ /* Shipping Countdown Element */ /*******************************************************************************************/ function createShippingCountdown() { var shippingDiv = document.createElement('div'); shippingDiv.className = 'shipping-countdown-alert'; function getArabicHourLabel(h) { if (h === 1) return 'ساعة'; if (h === 2) return 'ساعتين'; if (h >= 3 && h <= 10) return 'ساعات'; return 'ساعة'; } function getArabicMinuteLabel(m) { if (m === 1) return 'دقيقة'; if (m === 2) return 'دقيقتين'; if (m >= 3 && m <= 10) return 'دقائق'; return 'دقيقة'; } // Function to calculate time remaining until 12 noon GMT+3 function calculateTimeRemaining() { var now = new Date(); var utcTime = now.getTime() + (now.getTimezoneOffset() * 60000); var gmt3Time = new Date(utcTime + (3 * 3600000)); // GMT+3 var today = new Date(gmt3Time); var cutoffTime = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 12, 0, 0); // 12:00 PM GMT+3 // If it's already past 12 PM today, set cutoff for tomorrow if (gmt3Time > cutoffTime) { cutoffTime.setDate(cutoffTime.getDate() + 1); } var timeRemaining = cutoffTime.getTime() - gmt3Time.getTime(); if (timeRemaining <= 0) { return null; // Past cutoff time } var hours = Math.floor(timeRemaining / (1000 * 60 * 60)); var minutes = Math.floor((timeRemaining % (1000 * 60 * 60)) / (1000 * 60)); var seconds = Math.floor((timeRemaining % (1000 * 60)) / 1000); return { hours, minutes, seconds }; } // Function to update the countdown display function updateCountdown() { var now = new Date(); var utcTime = now.getTime() + (now.getTimezoneOffset() * 60000); var gmt3Time = new Date(utcTime + (3 * 3600000)); // GMT+3 var currentHour = gmt3Time.getHours(); var currentMinute = gmt3Time.getMinutes(); var currentDay = gmt3Time.getDay(); // 0 = Sunday, 5 = Friday // Hide on Friday OR outside 00:01–12:00 window if ( currentDay === 5 || // Friday currentHour > 12 || (currentHour === 0 && currentMinute === 0) ) { shippingDiv.style.display = 'none'; return; } else { shippingDiv.style.display = 'flex'; // Or 'block' depending on layout } var timeRemaining = calculateTimeRemaining(); if (!timeRemaining) { shippingDiv.style.display = 'none'; return; } var lineText = shippingDiv.querySelector('.shipping-line-text'); var hoursStr = timeRemaining.hours.toString().padStart(2, '0'); var minutesStr = timeRemaining.minutes.toString().padStart(2, '0'); if (htmlLang === "en") { lineText.innerHTML = `Ships today, order within ${hoursStr} hrs ${minutesStr} mins`; } else { lineText.innerHTML = `ينشحن اليوم اذا طلبت خلال ${hoursStr} ${getArabicHourLabel(timeRemaining.hours)} و${minutesStr} ${getArabicMinuteLabel(timeRemaining.minutes)}`; } } // Create the HTML structure shippingDiv.innerHTML = `
🚚
`; // Wait a short time to ensure DOM is rendered setTimeout(() => { updateCountdown(); setInterval(updateCountdown, 1000); }, 10); // Add the element before the Tamara section // waitForElement('.tamara-split-payment-section', (tamaraElement) => { // tamaraElement.insertAdjacentElement('beforebegin', shippingDiv); // }); return shippingDiv; } /*******************************************************************************************/ /* Size Guide */ /*******************************************************************************************/ function createSizeGuide() { var sizeguideLink = '#'; var priceGuideHeadline = htmlLang === "en" ? " " : " "; var sizeguideLink = htmlLang === "en" ? 'https://hawa.co/en/size-guide/page-222699345' : 'https://hawa.co/ar/size-guide/page-222699345'; var priceGuideLink = htmlLang === "en" ? 'Size Guide' : 'اعرف مقاسك في هوا'; var priceGuideLinkElement = `${priceGuideLink}`; var sizeLogo = ` `; var pdpForm = document.querySelector('#product-form'); var sizeGuideDiv = document.createElement('div'); sizeGuideDiv.className = 'size-guide-container'; // Create size guide elements var englishLink = document.createElement('div'); englishLink.className = 'size-guide-link-div'; englishLink.id = 'size-guide-link-div'; englishLink.innerHTML = priceGuideLinkElement + sizeLogo; var sizeGuideText = document.createElement('span'); sizeGuideText.textContent = priceGuideHeadline; sizeGuideText.className = 'size-guide-arabic'; sizeGuideDiv.appendChild(englishLink); sizeGuideDiv.appendChild(sizeGuideText); // Create modal but don't set up event listeners yet var modalOverlay = createSizeGuideModal(); document.body.appendChild(modalOverlay); // Move price div var priceDiv = pdpForm.querySelector(':scope > div:not(.size-guide-container)'); if (priceDiv) { priceDiv.classList.add('pdp-price-div'); pdpForm.insertBefore(priceDiv, pdpForm.firstChild); } // Return both the element and the modal for later event binding return { element: sizeGuideDiv, target: priceDiv, position: 'after', postRender: () => { setupSizeGuideEventListeners(modalOverlay); // Add click handler to stop animation const sizeGuideLink = document.querySelector('.size-guide-link-div'); const icon = document.querySelector('.Trigger__Icon'); if (sizeGuideLink && icon) { sizeGuideLink.addEventListener('click', (e) => { e.preventDefault(); icon.classList.add('animation-stopped'); modalOverlay.style.display = 'flex'; }); } } }; } /*******************************************************************************************/ /* Product Small USPs */ /*******************************************************************************************/ function createProductUSPs() { var inseamText = htmlLang === "en" ? "Made for daily wear" : "يناسب الثوب واللبس اليومي"; var microMeshText = htmlLang === "en" ? "Perfect length, eliminates chafing" : "يمنع الاحتكاك وما يتسلق فخذك"; var stretchText = htmlLang === "en" ? "Light, breathable and cool to the touch" : "قماش بارد وخفيف وناعم"; var seamsText = htmlLang === "en" ? "Stays put, no adjustment needed" : "ثابت ومايتسلق فخذك"; var bandText = htmlLang === "en" ? "Premium anti-roll waistband" : "حزام ناعم تنساه حول خصرك"; var materialText = htmlLang === "en" ? "Durable flatlock stitching" : "خياطة محبوكة، تعيش وضابطة على جسمك"; var careText = htmlLang === "en" ? "4-way stretch" : "مطاطي من كل الجهات"; var pouchText = htmlLang === "en" ? "3D contour pouch" : "مساحة أمامية تمنع الالتصاق"; var inseamImgSrc = "https://d17gg5c5d03gu7.cloudfront.net/pdp_prod_usps_thobe_1_krimud.svg"; var microMeshImgSrc = "https://d17gg5c5d03gu7.cloudfront.net/pdp_prod_usps_length_2_sbbj9j.svg"; var stretchImgSrc = "https://d17gg5c5d03gu7.cloudfront.net/pdp_prod_usps_cooling_3_emt7qj.svg"; var seamsImgSrc = "https://d17gg5c5d03gu7.cloudfront.net/pdp_prod_usps_thabit_4_ofgomz.svg"; var bandImgSrc = "https://d17gg5c5d03gu7.cloudfront.net/pdp_prod_usps_waistband_5_fumltn.svg"; var materialImgSrc = "https://d17gg5c5d03gu7.cloudfront.net/pdp_prod_usps_flatlock_6_qzmmlm.svg"; var careImgSrc = "https://d17gg5c5d03gu7.cloudfront.net/pdp_prod_usps_stretch_7_jj0v5l.svg"; var pouchImgSrc = "https://d17gg5c5d03gu7.cloudfront.net/pdp_prod_usps_pouch_8_llt6zt.svg"; var newDiv = document.createElement('div'); newDiv.classList.add('product-usp-parent-div'); newDiv.innerHTML = `

${htmlLang === 'ar' ? 'مزايا المنتج' : 'Product Features'}

`; var tarelement = document.querySelector('.product-single__info'); return { element: newDiv, target: tarelement, position: 'append' }; } function createUSPListItem(imgSrc, text) { return `
  • ${text}

  • `; } /*******************************************************************************************/ /* Brand USPs */ /*******************************************************************************************/ var arabicText = [ { icon: 'https://d17gg5c5d03gu7.cloudfront.net/brand-usp-easy-return-svg_vexnb2.svg', text: 'استبدال مجاني واسترجاع سهل' }, { icon: 'https://d17gg5c5d03gu7.cloudfront.net/brand-usp-truck-svg_znkigl.svg', text: `توصيل مجاني فوق 280 ر.س` }, { icon: 'https://d17gg5c5d03gu7.cloudfront.net/brand-usp-guarantee-svg_mdgmnp.svg', text: 'ماعجبك البوكسر؟ فلوسك ترجعلك' }, { icon: 'https://d17gg5c5d03gu7.cloudfront.net/brand-usp-24hr-svg_iiaggs.png', text: 'الرياض: توصيل خلال 48 ساعة' } ]; var englishText = [ { icon: 'https://d17gg5c5d03gu7.cloudfront.net/brand-usp-easy-return-svg_vexnb2.svg', text: 'Easy returns, free exchanges' }, { icon: 'https://d17gg5c5d03gu7.cloudfront.net/brand-usp-truck-svg_znkigl.svg', text: `Free delivery above 280` }, { icon: 'https://d17gg5c5d03gu7.cloudfront.net/brand-usp-guarantee-svg_mdgmnp.svg', text: 'We Guarantee Your First Boxer' }, { icon: 'https://d17gg5c5d03gu7.cloudfront.net/brand-usp-24hr-svg_iiaggs.png', text: '48hr delivery in Riyadh' } ]; var arabicDesktopText = [ { icon: 'https://d17gg5c5d03gu7.cloudfront.net/easy_return_brand_usp_desktop_pfsnkx.svg', text: 'استبدال مجاني واسترجاع سهل' }, { icon: 'https://d17gg5c5d03gu7.cloudfront.net/fast_delivery_brand_usp_desktop_ehbdiw.svg', text: `توصيل مجاني فوق 280 ر.س` }, { icon: 'https://d17gg5c5d03gu7.cloudfront.net/guarantee_first_boxer_brand_usp_desktop_avnlvg.svg', text: 'ماعجبك البوكسر؟ فلوسك ترجعلك' }, { icon: 'https://d17gg5c5d03gu7.cloudfront.net/24hr_desktop_brand_usp_ezllzj.svg', text: 'الرياض: توصيل خلال 48 ساعة' } ]; var englishDesktopText = [ { icon: 'https://d17gg5c5d03gu7.cloudfront.net/easy_return_brand_usp_desktop_pfsnkx.svg', text: 'Easy returns, free exchanges' }, { icon: 'https://d17gg5c5d03gu7.cloudfront.net/fast_delivery_brand_usp_desktop_ehbdiw.svg', text: `Free delivery above 280` }, { icon: 'https://d17gg5c5d03gu7.cloudfront.net/guarantee_first_boxer_brand_usp_desktop_avnlvg.svg', text: 'We Guarantee Your First Boxer' }, { icon: 'https://d17gg5c5d03gu7.cloudfront.net/24hr_desktop_brand_usp_ezllzj.svg', text: '48hr delivery in Riyadh' } ]; function createBrandUSPs(targetDiv) { var selectedText = htmlLang === 'en' ? englishText : arabicText; var selectedTextDesktop = htmlLang === 'en' ? englishDesktopText : arabicDesktopText; var container = document.createElement('div'); container.className = 'features-container-pdp'; container.classList.add('features-container'); var inner = document.createElement('div'); inner.className = 'features-inner'; var list = document.createElement('div'); list.className = 'features-list'; selectedText.forEach((item, index) => { // Create a wrapper div for the feature item var featureWrapper = document.createElement('div'); featureWrapper.className = 'feature-item'; // Create mobile icon var mobileIcon = document.createElement('img'); mobileIcon.src = item.icon; mobileIcon.alt = ''; mobileIcon.className = 'feature-icon mobile-icon'; // Create desktop icon using desktop-specific data var desktopIcon = document.createElement('img'); desktopIcon.src = selectedTextDesktop[index].icon; desktopIcon.alt = ''; desktopIcon.className = 'feature-icon desktop-icon'; // Create text element var text = document.createElement('p'); text.className = 'feature-text'; text.textContent = item.text; // Append elements to wrapper featureWrapper.appendChild(mobileIcon); featureWrapper.appendChild(desktopIcon); featureWrapper.appendChild(text); list.appendChild(featureWrapper); }); inner.appendChild(list); container.appendChild(inner); return { element: container, target: targetDiv, position: 'before-parent' }; } function createFeatureItem(item) { var featureItem = document.createElement('div'); featureItem.className = 'feature-item'; var icon = document.createElement('img'); icon.src = item.icon; icon.alt = ''; icon.className = 'feature-icon'; var text = document.createElement('p'); text.className = 'feature-text'; text.textContent = item.text; featureItem.appendChild(icon); featureItem.appendChild(text); return featureItem; } /*******************************************************************************************/ /* Product FAQ */ /*******************************************************************************************/ function createFAQSection(targetDiv) { var faqDiv = document.createElement('div'); faqDiv.className = 's-block--faq pdp-faq-section'; var currentPDPFAQs = faqDataPDP[htmlLang] || faqDataPDP.en; faqDiv.innerHTML = `

    ${htmlLang === "en" ? "FAQs" : "أسئلة عالبال"}

    ${currentPDPFAQs.map(faq => createFAQItem(faq)).join('')}
    `; initializeFAQHandlers(faqDiv); return { element: faqDiv, target: targetDiv, position: 'before-parent' }; } function createFAQItem(faq) { if(faq.question == `كيف أعرف المقاس المناسب لبوكسر هوا؟` || faq.question == `وش الحل لو أنا بين مقاسين؟`){ return `

    ${faq.answer}

    ${faq.link ? `${faq.linkText}` : ''}
    `; } return `

    ${faq.answer}

    ${faq.link ? `${faq.linkText}` : ''}
    `; } function initializeFAQHandlers(faqDiv) { faqDiv.querySelectorAll('.faq-size-link').forEach(link => { // Create and append the modal if it doesn't exist let modalOverlay = document.querySelector('.modal-overlay'); if (!modalOverlay) { modalOverlay = createSizeGuideModal(); document.body.appendChild(modalOverlay); } // Add click event to the CTA button link.addEventListener('click', () => { modalOverlay.style.display = 'flex'; }); // Set up modal close functionality const closeButton = modalOverlay.querySelector('.modal-close'); if (closeButton) { closeButton.addEventListener('click', () => { modalOverlay.style.display = 'none'; }); } // Close modal when clicking outside modalOverlay.addEventListener('click', (e) => { if (e.target === modalOverlay) { modalOverlay.style.display = 'none'; } }); }); faqDiv.querySelectorAll('.faq-btn').forEach(button => { button.addEventListener('click', () => { const faqItem = button.parentElement; const icon = button.querySelector('i'); // Toggle current FAQ const isOpen = faqItem.classList.contains('open'); if (isOpen) { faqItem.classList.remove('open'); icon.classList.remove('sicon-keyboard_arrow_up'); icon.classList.add('sicon-keyboard_arrow_down'); } else { faqItem.classList.add('open'); icon.classList.remove('sicon-keyboard_arrow_down'); icon.classList.add('sicon-keyboard_arrow_up'); } // Close other FAQs faqDiv.querySelectorAll('.single-faq').forEach(item => { if (item !== faqItem && item.classList.contains('open')) { item.classList.remove('open'); const otherIcon = item.querySelector('i'); otherIcon.classList.remove('sicon-keyboard_arrow_up'); otherIcon.classList.add('sicon-keyboard_arrow_down'); } }); }); }); } /*******************************************************************************************/ /* Product Instagram Gallery */ /*******************************************************************************************/ function createInstagramSection(targetDiv) { var targetElementinstaPDP = document.createElement('div'); if(htmlLang == 'en'){ targetElementinstaPDP.innerHTML= `

    `+instaTextEn+`

    ` } else { targetElementinstaPDP.innerHTML= `

    `+instaTextAr+`

    ` } return { element: targetElementinstaPDP, target: targetDiv, position: 'before-parent' }; } // Helper function to initialize Swiper function initializeGallerySwiper() { var initSwiper = () => { try { new Swiper('.gallery-swiper', { lazy: { loadPrevNext: true, loadPrevNextAmount: 2, }, breakpoints: { 320: { slidesPerView: 1.2, spaceBetween: 5, }, 768: { slidesPerView: 3, spaceBetween: 10, }, 1200: { slidesPerView: 4, spaceBetween: 20, }, }, speed: 400, grabCursor: true, preloadImages: false, watchSlidesProgress: true, resistance: true, resistanceRatio: 0.85, }); } catch(err) { setTimeout(initSwiper, 100); } }; initSwiper(); } /*******************************************************************************************/ /* Product Accordions */ /*******************************************************************************************/ function createAccordionSections(targetDiv) { var newDiv = document.createElement('div'); // Get current FAQ data based on language var currentPDPFAQs = faqDataPDP[htmlLang] || faqDataPDP.en; // Create FAQ HTML content var faqContent = currentPDPFAQs.map(faq => { return `

    ${faq.answer}

    ${faq.link ? `${faq.linkText}` : ''}
    `; }).join(''); newDiv.innerHTML = `
    ${shippingHeadline}

    ${shippingContent.replace(/\n/g, '
    ')}

    ${careInstructionsHeadline}

    ${careInstructionsContent.replace(/\n/g, '
    ')}

    ${firstPairGuaranteeHeadline}

    ${firstPairGuaranteeContent.replace(/\n/g, '
    ')}

    ${firstPairGuaranteeLinkText}
    ${fabricHeadline}

    ${fabricContent.replace(/\n/g, '
    ')}

    ${htmlLang === "en" ? "FAQs" : "أسئلة عالبال"}
    ${faqContent}
    `; initializeAccordions(newDiv); initializeFAQHandlers(newDiv); return { element: newDiv, target: targetDiv, position: 'after' }; } function initializeAccordions(accordionContainer) { var accordions = accordionContainer.querySelectorAll('.accordion-section'); accordions.forEach(accordion => { var header = accordion.querySelector('.accordion-header'); var content = accordion.querySelector('.accordion-content'); var button = accordion.querySelector('.accordion-button'); header.addEventListener('click', () => { var isOpen = content.style.display === 'block'; // Close all other accordion sections accordionContainer.querySelectorAll('.accordion-content').forEach(otherContent => { otherContent.style.display = 'none'; }); accordionContainer.querySelectorAll('.accordion-button').forEach(otherButton => { otherButton.textContent = '+'; }); // Toggle the current section content.style.display = isOpen ? 'none' : 'block'; button.textContent = isOpen ? '+' : '-'; }); }); } /*******************************************************************************************/ /* Product Step One USPs */ /*******************************************************************************************/ var USPtitle = 'وش يميز بوكسر هوا؟'; var USPtext2 = `ثابت، وانسى الاحتكاك` var USPsubtext2 = `تخيل إنك تلبس بوكسر ما يحتاج تعدله أبد، بوكسرنا مصمم بحيث يقلل الاحتكاك وما يتسلق فخوذك.`; var USPtext4 = `حزام النعومة والأمان` var USPsubtext4 = `حزام هوا ثابت بدون ما يضحي بالنعومة والراحة، وفوقها ما يتصفّط أو يتغير مع الاستخدام.`; var USPtext1 = `قماشنا أبرد` var USPsubtext1 = `زي ما قال أحد العملاء: "نفس شعور يوم تصلي الفجر وترجع تتلحف والجو برد كذا وسعادة"`; var USPtext3 = `شيّال وميّال` var USPsubtext3 = ` حطينا مساحة أمامية واسعة بحيث كل شي يقدر ياخذ راحته ونتجنب مشاكل الالتصاق المزعجة. `; if(htmlLang == 'en'){ USPtitle = 'What Makes Hawa Special?'; USPtext2 = `Chafe-free design` USPsubtext2 = `Longer inseam to prevent chafing, ride-up and wedgies. It will put an end to awkward adjustments in public.`; USPtext3 = `Premium anti-roll waistband` USPsubtext3 = `Super soft elastic waistband. It won't roll, pinch or leave any marks. You'll forget you're even wearing it.`; USPtext1 = `Cloud-like softness` USPsubtext1 = `LENZING™ Modal is a natural fiber that is softer, lighter and cooler than cotton. It is natually breathable and has 4-way stretch so you can move effortlessly.`; USPtext3 = `3D Contour Pouch` USPsubtext3 = `We understand the male anatomy - that's why we created this curved pouch to ensure everything is perfectly separated, supported and ventilated.`; } var USPurl2 = 'https://d17gg5c5d03gu7.cloudfront.net/2u.jpg'; var USPurl4 = 'https://d17gg5c5d03gu7.cloudfront.net/4u.jpg'; var USPurl1 = 'https://d17gg5c5d03gu7.cloudfront.net/1u.jpg'; var USPurl3 = 'https://d17gg5c5d03gu7.cloudfront.net/3u.jpg'; function createCustomSwiper(targetDiv) { // Only create if it doesn't exist if (document.querySelector("#custom-swiper-container")) { console.log("#custom-swiper-container already exists."); return null; } var sliderContainer = document.createElement("div"); sliderContainer.setAttribute("id", "custom-swiper-container"); sliderContainer.setAttribute("class", "swiper custom-swiper"); sliderContainer.innerHTML = `

    ${USPtitle}

    شيّال وميّال

    ${USPtext1}

    ${USPsubtext1}

    كما المودال

    ${USPtext2}

    ${USPsubtext2}

    حزام النعومة والأمان

    ${USPtext3}

    ${USPsubtext3}

    ثابت، وانسى الاحتكاك

    ${USPtext4}

    ${USPsubtext4}

    `; return { element: sliderContainer, target: targetDiv, position: 'after', postRender: () => initializeCustomSwiper() }; } function initializeCustomSwiper() { var initSwiper = () => { try { new Swiper('.custom-swiper', { direction: 'horizontal', loop: false, slidesPerView: 'auto', spaceBetween: 20, }); } catch(err) { setTimeout(initSwiper, 100); } }; initSwiper(); } /*******************************************************************************************/ /* Product Guarantee */ /*******************************************************************************************/ function createHawaGuarantee() { var guaranteeText = { en: { title: "First Pair Guarantee", description: "If you don't love your first pair, we will send you a different size or issue a full refund - no return required" }, ar: { title: "ضمان على هواك", description: "نضمن لك أول بوكسر في حال ما ناسبك خله عندك واستبدل المقاس أو نرجع لك فلوسك" } }; var language = document.documentElement.lang || 'en'; var text = guaranteeText[language]; var guaranteeDiv = document.createElement('div'); guaranteeDiv.className = 'hawa-guarantee-section'; guaranteeDiv.innerHTML = `

    ${text.title}

    ${text.description}

    `; var tarelement = document.querySelector('.product-single__info'); return { element: guaranteeDiv, target: tarelement, position: 'append' }; } /*******************************************************************************************/ /* Add to Cart USPs */ /*******************************************************************************************/ function createAddToCartUSPs() { var arabicText = [ { icon: "https://d17gg5c5d03gu7.cloudfront.net/brand-usp-guarantee-svg_mdgmnp.svg", text: "الضمان البلاتيني لمدة 30 يوم" }, { icon: "https://d17gg5c5d03gu7.cloudfront.net/brand-usp-easy-return-svg_vexnb2.svg", text: "استرجاع سهل واستبدال مجاني" }, { icon: "https://d17gg5c5d03gu7.cloudfront.net/brand-usp-24hr-svg_iiaggs.png", text: "توصيل مجاني فوق 280 ر.س" } ]; var englishText = [ { icon: "https://d17gg5c5d03gu7.cloudfront.net/brand-usp-guarantee-svg_mdgmnp.svg", text: "30-day try-on guarantee" }, { icon: "https://d17gg5c5d03gu7.cloudfront.net/brand-usp-easy-return-svg_vexnb2.svg", text: "Easy returns and free exchanges" }, { icon: "https://d17gg5c5d03gu7.cloudfront.net/brand-usp-24hr-svg_iiaggs.png", text: "Free shipping above 280 SAR" } ]; var selectedText = htmlLang === 'en' ? englishText : arabicText; var selectedTextDesktop = htmlLang === 'en' ? englishText : arabicText; var container = document.createElement('div'); container.className = 'add-to-cart-usps-container-pdp'; var inner = document.createElement('div'); inner.className = 'features-inner'; var list = document.createElement('div'); list.className = 'features-list'; selectedText.forEach((item, index) => { // Create a wrapper div for the feature item var featureWrapper = document.createElement('div'); featureWrapper.className = 'feature-item'; // Create mobile icon var mobileIcon = document.createElement('img'); mobileIcon.src = item.icon; mobileIcon.alt = ''; mobileIcon.className = 'feature-icon mobile-icon'; // Create text element var text = document.createElement('p'); text.className = 'feature-text'; text.textContent = item.text; // Append elements to wrapper featureWrapper.appendChild(mobileIcon); featureWrapper.appendChild(text); list.appendChild(featureWrapper); }); inner.appendChild(list); container.appendChild(inner); var targetElement = document.querySelector('.product-single__info'); return { element: container, target: targetElement, position: 'append' }; } function createFeatureItem(item) { var featureItem = document.createElement('div'); featureItem.className = 'feature-item'; var icon = document.createElement('img'); icon.src = item.icon; icon.alt = ''; icon.className = 'feature-icon'; var text = document.createElement('p'); text.className = 'feature-text'; text.textContent = item.text; featureItem.appendChild(icon); featureItem.appendChild(text); return featureItem; } /*******************************************************************************************/ /* Add to Cart Tamara Section */ /*******************************************************************************************/ function createTamaraSplitPaymentSection() { // Get the price from the selector var priceElement = document.querySelector('#product-form').querySelector('.starting-or-normal-price').querySelector('.total-price'); if (!priceElement) { console.error('Price element not found'); return null; } // Create the element var tamaraDiv = document.createElement('div'); tamaraDiv.className = 'tamara-split-payment-section'; // Function to calculate and update installment amount function updateInstallmentAmount() { // Extract the number from price text var priceText = priceElement.textContent.trim(); var priceMatch = priceText.match(/\d+(\.\d+)?/); if (!priceMatch) { console.error('Could not extract price from', priceText); return; } var totalPrice = parseFloat(priceMatch[0]); var installmentAmount = (totalPrice / 4).toFixed(2); // Content in multiple languages var tamContent = { en: { text: `Split your total into 4 installments of ${installmentAmount} SAR with`, logoAlt: "Tamara Logo" }, ar: { text: `قسم فاتورتك على 4 دفعات بقيمة ${installmentAmount} ر.س مع`, logoAlt: "شعار تمارا" } }; var language = document.documentElement.lang || 'en'; var content = tamContent[language]; // Update the HTML content tamaraDiv.innerHTML = `
    ${content.text}
    `; } // Initial calculation updateInstallmentAmount(); // Set up a MutationObserver to watch for changes to the price element var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.type === 'childList' || mutation.type === 'characterData') { updateInstallmentAmount(); } }); }); // Configure and start the observer var observerConfig = { childList: true, characterData: true, subtree: true }; observer.observe(priceElement, observerConfig); // Return the element for insertion var targetElement = document.querySelector('.product-single__info'); return { element: tamaraDiv, target: targetElement, position: 'append' }; } /*******************************************************************************************/ /* Product Comparison */ /*******************************************************************************************/ var comparisonContent = { ar: { title: 'بوكسر هـــوا والبوكسرات الثانية', description: 'قبل مانسوي بوكسر هوا، جربنا كل شي متاح في السوق، واستوعبنا إن فيه مشاكل واضحة ومختلفة في كل البوكسرات الثانية. عشان كذا صممنا بوكسر هوا بطريقة تفهم جسمك، وقماش يريح جلدك، وثبات يساعدك تتحرك وبدون مايحكحك بين فخوذك. بالضبط ولا غلطة.', imageUrl: 'https://cdn.salla.sa/form-builder/JpD6z9cGDcDjEGmZDQzFZSEJluviSVUQvJtgvO7g.png', imageAlt: 'About store image' }, en: { title: 'Hawa vs. Other Brands', description: `Before launching Hawa, we pretty much tried every boxer brief available on the market. Nothing checked all the boxes, each one had its own set of issues. So, we had to make our own design to be the the be-all and end-all of underwear.\n\nOur boxer brief is super soft, breathable, anti-chafing, anti ride-up and anti-adjusting. On top of that, it has the perfect curved pouch to keep your boys cradled and separated from the rest of your body.`, imageUrl: 'https://cdn.salla.sa/form-builder/JpD6z9cGDcDjEGmZDQzFZSEJluviSVUQvJtgvO7g.png', imageAlt: 'About store image' } }; function createVideoComparison(targetDiv) { var htmlLang = document.documentElement.lang || 'ar'; var lang = htmlLang.split('-')[0]; var content = comparisonContent[lang] || comparisonContent['ar']; var comparisonDiv = document.createElement('div'); comparisonDiv.className = 'hawa-video-comparison'; comparisonDiv.innerHTML = `

    ${content.title}

    ${content.description}

    `; return { element: comparisonDiv, target: targetDiv, position: 'after' }; } /*******************************************************************************************/ /* Product Comparison Table */ /*******************************************************************************************/ function createTableComparison(targetDiv) { var language = document.documentElement.lang; var faqDiv = document.createElement('div'); faqDiv.className = 'hawa-table-comparison'; var checkSvg = "https://d17gg5c5d03gu7.cloudfront.net/comparison_table_checkmark_zyugxx.svg"; var crossSvg = "https://d17gg5c5d03gu7.cloudfront.net/comparison_table_x_mark_lokoyo.svg"; var comparisonImage = "https://d17gg5c5d03gu7.cloudfront.net/comparison_table_desktop_image_cdtlrz.png"; // Replace with your actual image URL // Define translations and language-specific logos var translations = { en: { hawa: 'HAWA', otherBrands: 'Local Brands', logoSrc: "https://d17gg5c5d03gu7.cloudfront.net/comparison_table_logo_ar_xm7mm2.svg", features: [ 'No Chafing', 'No Ride-Up', '3D Contour Pouch', 'Soft And Cool Fabric', 'Anti-Roll Waistband', 'First Pair Guarantee' ] }, ar: { hawa: 'هوا', otherBrands: 'البراندات المحلية', logoSrc: "https://d17gg5c5d03gu7.cloudfront.net/comparison_table_logo_ar_xm7mm2.svg", features: [ 'يمنع الاحتكاك', 'ثابت ومايتسلق فخوذك', 'مساحة امامية تمنع الالتصاق', 'قماشه بارد وناعم', 'حزامه تنساه حول خصرك', 'عليه ضمان' ] } }; var beforelastFeature = htmlLang == 'en' ? 'Suitable for Thoub' : 'مناسب للثوب'; var lastFeature = htmlLang == 'en' ? 'Cheap' : 'سعره رخيص'; var lastFeatureNote = htmlLang == 'en' ? '*But worth it' : '*بس يستاهل'; // Select the appropriate translations var text = translations[language] || translations.en; // Add container class for homepage-specific styling faqDiv.innerHTML = `
    ${text.otherBrands}
    ${text.features.map(feature => `
    ${feature}
    check
    cross
    `).join('')}
    ${beforelastFeature}
    check
    check
    ${lastFeature}
    * check *
    cross
    ${lastFeatureNote}
    Comparison
    `; return { element: faqDiv, target: targetDiv, position: 'after' }; } /*******************************************************************************************/ /* Product Table Comparison */ /*******************************************************************************************/ var translations = { en: { hawa: 'HAWA', otherBrands: 'Local Brands', logoSrc: "https://d17gg5c5d03gu7.cloudfront.net/comparison_table_logo_ar_xm7mm2.svg", features: [ 'No Chafing', 'No Ride-Up', '3D Contour Pouch', 'Soft And Cool Fabric', 'Anti-Roll Waistband', 'First Pair Guarantee', 'Suitable for Thoub' ] }, ar: { hawa: 'هوا', otherBrands: 'البراندات المحلية', logoSrc: "https://d17gg5c5d03gu7.cloudfront.net/comparison_table_logo_ar_xm7mm2.svg", features: [ 'يمنع الاحتكاك', 'ثابت ومايتسلق فخوذك', 'مساحة امامية تمنع الالتصاق', 'قماشه بارد وناعم', 'حزامه تنساه حول خصرك', 'عليه ضمان', 'مناسب للثوب' ] } }; function createFabricComparisonPDP(targetDiv) { var translations = { en: { title: "Why is Modal Better than Cotton?", subtitle: `
    3x
    Softer than cotton
    50%
    Higher moisture absorption
    100%
    Natural
    Fabric composition: 91% Lenzing™ Modal and 9% Elastane`, modalLabel: "91% Modal", cottonLabel: "Cotton" }, ar: { title: "ليش قماش المودال أحسن من القطن؟", subtitle: `
    3x
    نعومة القطن
    50%
    إمتصاص أعلى للرطوبة
    100%
    طبيعي
    وهذا يخلي تكلفة قماش المودال 2 إلى 3 أضعاف أغلى من القطن العادي بسبب جودته العالية، وفي هوا مانستخدم إلا أفضل وأجود أنواع الأقمشة.`, cottonLabel: "مودال (™Lenzing)", modalLabel: "القطن" } }; var language = document.documentElement.lang || 'en'; var text = translations[language]; var dir = language === 'ar' ? 'rtl' : 'ltr'; var fabricContainer = document.createElement('div'); fabricContainer.className = 'fabric-container-pdp'; fabricContainer.innerHTML = `

    ${text.title}

    ${text.subtitle}
    Fabric comparison showing modal fabric texture on the left and cotton fabric texture on the right
    ${text.modalLabel}
    ${text.cottonLabel}
    `; return { element: fabricContainer, target: targetDiv, position: 'after' }; } /*******************************************************************************************/ /* Initialize PDP Elements */ /*******************************************************************************************/ function initializePDPElements() { var targetDiv = document.querySelector('.product-271747864') || document.querySelector('.product-2130693625') || document.querySelector('.product-1716601874') || document.querySelector('.product-727834477') || document.querySelector('.product-1306857438') || // NATIONAL DAY PRODUCTS CHANGES HERE document.querySelector('.product-50512583') || document.querySelector('.product-723306792') || document.querySelector('.product-2067310458') || document.querySelector('.product-1344181453') || document.querySelector('.product-1727535782'); if (!targetDiv) { console.log('Target div not found'); return; } var targetDivFooter = document.querySelector('.store-footer'); if (!targetDivFooter) { console.log('Target footer div not found'); return; } try { // Initialize components in order var components = [ createProductInfo(), createStarsRating(), createSizeGuide(), // createHawaGuarantee(), createTamaraSplitPaymentSection(), createAddToCartUSPs(), createProductUSPs(), createBrandUSPs(targetDivFooter), // createInstagramSection(targetDivFooter), createFAQSection(targetDivFooter), createFabricComparisonPDP(targetDiv), createCustomSwiper(targetDiv), // Add the custom swiper createTableComparison(targetDiv), createVideoComparison(targetDiv), createAccordionSections(targetDiv) ]; // Initialize swiper // initializeSwiper(); createLowStockAlert(); createShippingCountdown(); // Render components and handle post-render actions components.forEach(component => { if (!component) { console.log('Skipping null component'); return; } var { element, target, position, postRender } = component; if (!element || !target) { console.log('Missing element or target for component'); return; } try { switch (position) { case 'prepend': target.insertBefore(element, target.firstChild); break; case 'append': target.appendChild(element); break; case 'after': target.insertAdjacentElement('afterend', element); break; case 'before-parent': target.parentNode.insertBefore(element, target); break; default: console.log(`Unknown position: ${position}`); } if (postRender && typeof postRender === 'function') { postRender(); } } catch (error) { console.error('Error inserting component:', error); } }); } catch (error) { console.error('Error initializing PDP elements:', error); } } // Initialize everything initializePDPElements(); /*******************************************************************************************/ /************* Create Bundle Discounts on One Boxer PDP ****************/ /*******************************************************************************************/ // var interval; // let _r = 0; // interval = setInterval(function(){ // if (document.getElementById('offer-container') || _r == 3) { // clearInterval(interval); // return false; // } // else { // let t = document.createElement("div"), // o = ""; // t.id = "offer-container"; // var targetElement = document.querySelector("salla-payments"); // if (targetElement) { // targetElement.insertAdjacentElement("afterend", t); // } // else { // console.log('Target element for offer container not found 1'); // targetElement = document.querySelectorAll("salla-quick-order")[1]; // if (targetElement) { // targetElement.insertAdjacentElement("afterend", t); // } // else { // console.log('Target element for offer container not found 2'); // } // } // let r = document.querySelector(".s-quantity-input-input"); // // Language translations // var translations = { // en: { // bundleTitle: "Bundle & Save", // bundleSubTitle: "Discount Auto-applied After Selection - Mix and Match", // buyText: "Buy", // saveText: "Save", // perUnit: "per unit" // }, // ar: { // bundleTitle: "كل ما زدت كل ما وفرت", // bundleSubTitle: "الخصم يطبق تلقائياً بعد الإضافة - شكّل ونوّع زي ما تبي", // buyText: "اشتر", // saveText: "ووفر", // perUnit: "للقطعة" // } // }; // // Get current language from HTML tag // var currentLang = document.documentElement.lang || 'en'; // var txt = translations[currentLang] || translations.en; // function n(t) { // let e = document.createElement("style"); // e.type = "text/css", e.appendChild(document.createTextNode(t)), document.head.appendChild(e) // } // let a = ` // `; // n(a); // let d = window.location.href, // l = function t(e) { // let i = e.match(/\/p(\d+)$/); // if(!i) {clearInterval(interval); return false;} // return i ? i[1] : null // }(d); // var bundles; // if (l == "1716601874") { // bundles = [ // { // quantity: document.documentElement.lang === 'ar' ? '2' : '2', // item: document.documentElement.lang === 'ar' ? '' : '', // discount: document.documentElement.lang === 'ar' ? '6' : '6', // pricePerUnit: document.documentElement.lang === 'ar' ? '65' : '65' // }, // { // quantity: document.documentElement.lang === 'ar' ? '3' : '3', // item: document.documentElement.lang === 'ar' ? '' : '', // discount: document.documentElement.lang === 'ar' ? '10' : '10', // pricePerUnit: document.documentElement.lang === 'ar' ? '62' : '62' // } // ]; // } // else { // return; // } // var quantityEnglish = {'2': '2', '4': '4', '8': '8', '12': '12'}; // function generateBundleOptions() { // o = ""; // var originalPrice = document.documentElement.lang === 'ar' ? '69' : '69'; // var currency = document.documentElement.lang === 'ar' ? `` : ``; // bundles.forEach((bundle, index) => { // o += ` //
    // // //
    `; // }); // t.innerHTML = ` //
    //

    ${txt.bundleTitle}

    // ${txt.bundleSubTitle} //
    ${o}
    //
    `; // } // generateBundleOptions(); // } // }, 1000); /*******************************************************************************************/ /************* Add Bundle Links *******************************************/ /*******************************************************************************************/ // National Day Products Changes Here var onePieceOptionTitle = htmlLang === "en" ? "1-Pack" : "عدد 1"; var fourPieceOptionTitle = htmlLang === "en" ? "4-Pack" : "عدد 4"; var eightPieceOptionTitle = htmlLang === "en" ? "8-Pack" : "عدد 8"; var twelvePieceOptionTitle = htmlLang === "en" ? "12-Pack" : "عدد 12"; // var onePieceOptionTitle = htmlLang === "en" ? "1-Pack" : "عدد 1"; // var fourPieceOptionTitle = htmlLang === "en" ? "4 + 1 Free" : "عدد 4 + 1 مجاناً"; // var eightPieceOptionTitle = htmlLang === "en" ? "8 + 2 Free" : "عدد 8 + 2 مجاناً"; // var twelvePieceOptionTitle = htmlLang === "en" ? "12 + 4 Free" : "عدد 12 + 4 مجاناً"; var onePieceOptionPrice = htmlLang === "en" ? "69" : "69"; var onePieceOptionPriceUpsell = htmlLang === "en" ? "64" : "64"; // var fourPieceOptionPrice = htmlLang === "en" ? "59" : "59"; var fourPieceOptionPriceUpsell = htmlLang === "en" ? "53" : "53"; var fourPieceOptionPrice = htmlLang === "en" ? "59" : "59"; var fourPieceFullPrice = htmlLang === "en" ? "276" : "276"; // var eightPieceOptionPrice = htmlLang === "en" ? "54" : "54"; var eightPieceOptionPriceUpsell = htmlLang === "en" ? "52" : "52"; var eightPieceOptionPrice = htmlLang === "en" ? "55" : "55"; var eightPieceFullPrice = htmlLang === "en" ? "552" : "552"; // var twelvePieceOptionPrice = htmlLang === "en" ? "49" : "49"; var twelvePieceOptionPriceUpsell = htmlLang === "en" ? "45" : "45"; var twelvePieceOptionPrice = htmlLang === "en" ? "49" : "49"; var twelvePieceFullPrice = htmlLang === "en" ? "828" : "828"; var perPieceText = htmlLang === "en" ? "per piece" : "/ قطعة"; var perPieceTextNDS = htmlLang === "en" ? "" : ""; var currencyText = htmlLang === "en" ? `` : ``; var onePieceOptionLink = `https://hawa.co/${htmlLang}/%D8%A8%D9%88%D9%83%D8%B3%D8%B1-%D9%87%D9%88%D8%A7/p1716601874`; var fourPieceOptionLink = `https://hawa.co/${htmlLang}/%D8%A8%D9%88%D9%83%D8%B3%D8%B1-%D9%87%D9%88%D8%A7-4-%D9%82%D8%B7%D8%B9%D8%A9/p2130693625`; var eightPieceOptionLink = `https://hawa.co/${htmlLang}/%D8%A8%D9%88%D9%83%D8%B3%D8%B1-%D9%87%D9%88%D8%A7-8-%D9%82%D8%B7%D8%B9%D8%A9/p271747864`; var twelvePieceOptionLink = `https://hawa.co/${htmlLang}/%D8%A8%D9%88%D9%83%D8%B3%D8%B1-%D9%87%D9%88%D8%A7-12-%D9%82%D8%B7%D8%B9%D8%A9/p1306857438`; var onePieceOptionLinkBlack = `https://hawa.co/${htmlLang}/%D8%A8%D9%88%D9%83%D8%B3%D8%B1-%D9%87%D9%88%D8%A7/p50512583`; var fourPieceOptionLinkBlack = `https://hawa.co/${htmlLang}/%D8%A8%D9%88%D9%83%D8%B3%D8%B1-%D9%87%D9%88%D8%A7-4-%D9%82%D8%B7%D8%B9%D8%A9/p723306792`; var eightPieceOptionLinkBlack = `https://hawa.co/${htmlLang}/%D8%A8%D9%88%D9%83%D8%B3%D8%B1-%D9%87%D9%88%D8%A7-8-%D9%82%D8%B7%D8%B9%D8%A9/p2067310458`; var twelvePieceOptionLinkBlack = `https://hawa.co/${htmlLang}/%D8%A8%D9%88%D9%83%D8%B3%D8%B1-%D9%87%D9%88%D8%A7-12-%D9%82%D8%B7%D8%B9%D8%A9/p1727535782`; // var fourPieceOptionDiscount = htmlLang === "en" ? "Save 15" : "وفّر 15"; var fourPieceOptionDiscount = htmlLang === "en" ? "Save 14" : "وفّر 14"; // var eightPieceOptionDiscount = htmlLang === "en" ? "Save 21" : "وفّر 21"; var eightPieceOptionDiscount = htmlLang === "en" ? "Save 20" : "وفّر 20"; // var twelvePieceOptionDiscount = htmlLang === "en" ? "Save 29" : "وفّر 29"; var twelvePieceOptionDiscount = htmlLang === "en" ? "Save 29" : "وفّر 29"; var freeShippingText = htmlLang === "en" ? "Free Shipping" : "شحن مجاني"; var BestSellerText = htmlLang === "en" ? "Best Seller" : "الأكثر مبيعا"; var bundleOptionsTitle = htmlLang === "en" ? "Packs" : "البكجات"; // 1 Pack waitForElement('.product-1716601874', (prodDiv) => { var linksdiv = document.createElement('div'); linksdiv.classList.add('bundle-options-links'); linksdiv.innerHTML = `

    ${bundleOptionsTitle}

    ${BestSellerText ? `${BestSellerText}` : ''} ${fourPieceOptionDiscount ? `${fourPieceOptionDiscount}%` : ''}
    ${fourPieceOptionTitle}
    ${fourPieceOptionPrice} ${currencyText} ${perPieceText}
    ${freeShippingText ? `${freeShippingText}` : ''} ${eightPieceOptionDiscount ? `${eightPieceOptionDiscount}%` : ''}
    ${eightPieceOptionTitle}
    ${eightPieceOptionPrice} ${currencyText} ${perPieceText}
    ${freeShippingText ? `${freeShippingText}` : ''} ${twelvePieceOptionDiscount ? `${twelvePieceOptionDiscount}%` : ''}
    ${twelvePieceOptionTitle}
    ${twelvePieceOptionPrice} ${currencyText} ${perPieceText}
    `; waitForElement('.s-product-options-option-container', (opttemp) => { var options = prodDiv.querySelectorAll('.s-product-options-option-container') // if (options.length > 1) { // options[1].style = 'display: none' // } var fields = prodDiv.querySelector('salla-product-options'); fields.insertBefore(linksdiv, fields.querySelector('salla-conditional-fields')); }); }); // 4 Pack waitForElement('.product-2130693625', (prodDiv) => { var linksdiv = document.createElement('div'); linksdiv.classList.add('bundle-options-links'); linksdiv.innerHTML = `

    ${bundleOptionsTitle}

    ${BestSellerText ? `${BestSellerText}` : ''} ${fourPieceOptionDiscount ? `${fourPieceOptionDiscount}%` : ''}
    ${fourPieceOptionTitle}
    ${fourPieceOptionPrice} ${currencyText} ${perPieceText}
    ${freeShippingText ? `${freeShippingText}` : ''} ${eightPieceOptionDiscount ? `${eightPieceOptionDiscount}%` : ''}
    ${eightPieceOptionTitle}
    ${eightPieceOptionPrice} ${currencyText} ${perPieceText}
    ${freeShippingText ? `${freeShippingText}` : ''} ${twelvePieceOptionDiscount ? `${twelvePieceOptionDiscount}%` : ''}
    ${twelvePieceOptionTitle}
    ${twelvePieceOptionPrice} ${currencyText} ${perPieceText}
    `; waitForElement('.s-product-options-option-container', (opttemp) => { var priceDiv = document.querySelector('.pdp-price-div').querySelector('.starting-or-normal-price'); var pricePieceDiv = document.createElement('div'); pricePieceDiv.classList.add('price-piece-div'); // Function to update the original price function updateOriginalPrice() { // Get the current price from the price element var priceText = priceDiv.querySelector('.total-price').textContent.trim(); var priceMatch = priceText.match(/\d+(\.\d+)?/); if (priceMatch) { var currentPrice = parseFloat(priceMatch[0]); // Calculate the original price (assuming 15% discount as per fourPieceOptionDiscount) // // var calculatedOriginalPrice = (currentPrice / 0.85).toFixed(0); var calculatedOriginalPrice = (currentPrice / 0.86).toFixed(0); pricePieceDiv.innerHTML = ` ${calculatedOriginalPrice} ${currencyText} `; } } // Initial setup updateOriginalPrice(); priceDiv.appendChild(pricePieceDiv); // Set up observer to watch for price changes var priceElement = priceDiv.querySelector('.total-price'); if (priceElement) { var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.type === 'childList' || mutation.type === 'characterData') { updateOriginalPrice(); } }); }); var observerConfig = { childList: true, characterData: true, subtree: true }; observer.observe(priceElement, observerConfig); } // Continue with the rest of the code var priceDiv2 = document.querySelector('.pdp-price-div'); var pricePieceDiv2 = document.createElement('div'); pricePieceDiv2.classList.add('price-piece-div2'); pricePieceDiv2.innerHTML = ` ${fourPieceOptionPrice} ${currencyText} ${perPieceText} ${perPieceTextNDS} `; priceDiv2.appendChild(pricePieceDiv2); // Observe upsell selection changes and update per-piece price accordingly (function() { var basePerPiecePrice = fourPieceOptionPrice; function updatePerPieceForUpsell() { var isUpsellSelected = !!(prodDiv.querySelector('.size-option-upsell.selected')); var newPriceText = basePerPiecePrice; if (isUpsellSelected) { newPriceText = fourPieceOptionPriceUpsell; } pricePieceDiv2.innerHTML = ` ${newPriceText} ${currencyText} ${perPieceText} ${perPieceTextNDS} `; } updatePerPieceForUpsell(); var upsellContainer = prodDiv.querySelector('.size-option-upsell') ? prodDiv.querySelector('.size-option-upsell').parentElement : null; if (upsellContainer) { upsellContainer.addEventListener('click', function(e) { if (e.target && e.target.closest('.size-option')) { updatePerPieceForUpsell(); } }); var selectionObserver = new MutationObserver(function() { updatePerPieceForUpsell(); }); selectionObserver.observe(upsellContainer, { attributes: true, subtree: true, attributeFilter: ['class'] }); } })(); var options = prodDiv.querySelectorAll('.s-product-options-option-container') // if (options.length > 1) { // options[1].style = 'display: none' // } var fields = prodDiv.querySelector('salla-product-options'); fields.insertBefore(linksdiv, fields.querySelector('salla-conditional-fields')); }); }); // 8 Pack waitForElement('.product-271747864', (prodDiv) => { var linksdiv = document.createElement('div'); linksdiv.classList.add('bundle-options-links'); linksdiv.innerHTML = `

    ${bundleOptionsTitle}

    ${BestSellerText ? `${BestSellerText}` : ''} ${fourPieceOptionDiscount ? `${fourPieceOptionDiscount}%` : ''}
    ${fourPieceOptionTitle}
    ${fourPieceOptionPrice} ${currencyText} ${perPieceText}
    ${freeShippingText ? `${freeShippingText}` : ''} ${eightPieceOptionDiscount ? `${eightPieceOptionDiscount}%` : ''}
    ${eightPieceOptionTitle}
    ${eightPieceOptionPrice} ${currencyText} ${perPieceText}
    ${freeShippingText ? `${freeShippingText}` : ''} ${twelvePieceOptionDiscount ? `${twelvePieceOptionDiscount}%` : ''}
    ${twelvePieceOptionTitle}
    ${twelvePieceOptionPrice} ${currencyText} ${perPieceText}
    `; waitForElement('.s-product-options-option-container', (opttemp) => { var priceDiv = document.querySelector('.pdp-price-div').querySelector('.starting-or-normal-price'); var pricePieceDiv = document.createElement('div'); pricePieceDiv.classList.add('price-piece-div'); // Function to update the original price function updateOriginalPrice() { // Get the current price from the price element var priceText = priceDiv.querySelector('.total-price').textContent.trim(); var priceMatch = priceText.match(/\d+(\.\d+)?/); if (priceMatch) { var currentPrice = parseFloat(priceMatch[0]); // Calculate the original price (assuming 21% discount as per eightPieceOptionDiscount) // // var calculatedOriginalPrice = (currentPrice / 0.79).toFixed(0); var calculatedOriginalPrice = (currentPrice / 0.8).toFixed(0); pricePieceDiv.innerHTML = ` ${calculatedOriginalPrice} ${currencyText} `; } } // Initial setup updateOriginalPrice(); priceDiv.appendChild(pricePieceDiv); // Set up observer to watch for price changes var priceElement = priceDiv.querySelector('.total-price'); if (priceElement) { var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.type === 'childList' || mutation.type === 'characterData') { updateOriginalPrice(); } }); }); var observerConfig = { childList: true, characterData: true, subtree: true }; observer.observe(priceElement, observerConfig); } // Continue with the rest of the code var priceDiv2 = document.querySelector('.pdp-price-div'); var pricePieceDiv2 = document.createElement('div'); pricePieceDiv2.classList.add('price-piece-div2'); pricePieceDiv2.innerHTML = ` ${eightPieceOptionPrice} ${currencyText} ${perPieceText} ${perPieceTextNDS} `; priceDiv2.appendChild(pricePieceDiv2); // Observe upsell selection changes and update per-piece price accordingly (function() { var basePerPiecePrice = eightPieceOptionPrice; function updatePerPieceForUpsell() { var isUpsellSelected = !!(prodDiv.querySelector('.size-option-upsell.selected')); var newPriceText = basePerPiecePrice; if (isUpsellSelected) { newPriceText = eightPieceOptionPriceUpsell; } pricePieceDiv2.innerHTML = ` ${newPriceText} ${currencyText} ${perPieceText} ${perPieceTextNDS} `; } updatePerPieceForUpsell(); var upsellContainer = prodDiv.querySelector('.size-option-upsell') ? prodDiv.querySelector('.size-option-upsell').parentElement : null; if (upsellContainer) { upsellContainer.addEventListener('click', function(e) { if (e.target && e.target.closest('.size-option')) { updatePerPieceForUpsell(); } }); var selectionObserver = new MutationObserver(function() { updatePerPieceForUpsell(); }); selectionObserver.observe(upsellContainer, { attributes: true, subtree: true, attributeFilter: ['class'] }); } })(); var options = prodDiv.querySelectorAll('.s-product-options-option-container') // if (options.length > 1) { // options[1].style = 'display: none' // } var fields = prodDiv.querySelector('salla-product-options'); fields.insertBefore(linksdiv, fields.querySelector('salla-conditional-fields')); }); }); // 12 Pack waitForElement('.product-1306857438', (prodDiv) => { var linksdiv = document.createElement('div'); linksdiv.classList.add('bundle-options-links'); linksdiv.innerHTML = `

    ${bundleOptionsTitle}

    ${BestSellerText ? `${BestSellerText}` : ''} ${fourPieceOptionDiscount ? `${fourPieceOptionDiscount}%` : ''}
    ${fourPieceOptionTitle}
    ${fourPieceOptionPrice} ${currencyText} ${perPieceText}
    ${freeShippingText ? `${freeShippingText}` : ''} ${eightPieceOptionDiscount ? `${eightPieceOptionDiscount}%` : ''}
    ${eightPieceOptionTitle}
    ${eightPieceOptionPrice} ${currencyText} ${perPieceText}
    ${freeShippingText ? `${freeShippingText}` : ''} ${twelvePieceOptionDiscount ? `${twelvePieceOptionDiscount}%` : ''}
    ${twelvePieceOptionTitle}
    ${twelvePieceOptionPrice} ${currencyText} ${perPieceText}
    `; waitForElement('.s-product-options-option-container', (opttemp) => { var priceDiv = document.querySelector('.pdp-price-div').querySelector('.starting-or-normal-price'); var pricePieceDiv = document.createElement('div'); pricePieceDiv.classList.add('price-piece-div'); // Function to update the original price function updateOriginalPrice() { // Get the current price from the price element var priceText = priceDiv.querySelector('.total-price').textContent.trim(); var priceMatch = priceText.match(/\d+(\.\d+)?/); if (priceMatch) { var currentPrice = parseFloat(priceMatch[0]); // Calculate the original price (assuming 29% discount as per twelvePieceOptionDiscount) ////var calculatedOriginalPrice = (currentPrice / 0.71).toFixed(0); var calculatedOriginalPrice = (currentPrice / 0.71).toFixed(0); pricePieceDiv.innerHTML = ` ${calculatedOriginalPrice} ${currencyText} `; } } // Initial setup updateOriginalPrice(); priceDiv.appendChild(pricePieceDiv); // Set up observer to watch for price changes var priceElement = priceDiv.querySelector('.total-price'); if (priceElement) { var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.type === 'childList' || mutation.type === 'characterData') { updateOriginalPrice(); } }); }); var observerConfig = { childList: true, characterData: true, subtree: true }; observer.observe(priceElement, observerConfig); } // Continue with the rest of the code var priceDiv2 = document.querySelector('.pdp-price-div'); var pricePieceDiv2 = document.createElement('div'); pricePieceDiv2.classList.add('price-piece-div2'); pricePieceDiv2.innerHTML = ` ${twelvePieceOptionPrice} ${currencyText} ${perPieceText} ${perPieceTextNDS} `; priceDiv2.appendChild(pricePieceDiv2); // Observe upsell selection changes and update per-piece price accordingly (function() { var basePerPiecePrice = twelvePieceOptionPrice; function updatePerPieceForUpsell() { var isUpsellSelected = !!(prodDiv.querySelector('.size-option-upsell.selected')); var newPriceText = basePerPiecePrice; if (isUpsellSelected) { newPriceText = twelvePieceOptionPriceUpsell; } pricePieceDiv2.innerHTML = ` ${newPriceText} ${currencyText} ${perPieceText} ${perPieceTextNDS} `; } updatePerPieceForUpsell(); var upsellContainer = prodDiv.querySelector('.size-option-upsell') ? prodDiv.querySelector('.size-option-upsell').parentElement : null; if (upsellContainer) { upsellContainer.addEventListener('click', function(e) { if (e.target && e.target.closest('.size-option')) { updatePerPieceForUpsell(); } }); var selectionObserver = new MutationObserver(function() { updatePerPieceForUpsell(); }); selectionObserver.observe(upsellContainer, { attributes: true, subtree: true, attributeFilter: ['class'] }); } })(); var options = prodDiv.querySelectorAll('.s-product-options-option-container') // if (options.length > 1) { // options[1].style = 'display: none' // } var fields = prodDiv.querySelector('salla-product-options'); fields.insertBefore(linksdiv, fields.querySelector('salla-conditional-fields')); }); }); // 1 Pack Black Pack waitForElement('.product-50512583', (prodDiv) => { var linksdiv = document.createElement('div'); linksdiv.classList.add('bundle-options-links'); linksdiv.innerHTML = `

    ${bundleOptionsTitle}

    ${BestSellerText ? `${BestSellerText}` : ''} ${fourPieceOptionDiscount ? `${fourPieceOptionDiscount}%` : ''}
    ${fourPieceOptionTitle}
    ${fourPieceOptionPrice} ${currencyText} ${perPieceText}
    ${freeShippingText ? `${freeShippingText}` : ''} ${eightPieceOptionDiscount ? `${eightPieceOptionDiscount}%` : ''}
    ${eightPieceOptionTitle}
    ${eightPieceOptionPrice} ${currencyText} ${perPieceText}
    ${freeShippingText ? `${freeShippingText}` : ''} ${twelvePieceOptionDiscount ? `${twelvePieceOptionDiscount}%` : ''}
    ${twelvePieceOptionTitle}
    ${twelvePieceOptionPrice} ${currencyText} ${perPieceText}
    `; waitForElement('.s-product-options-option-container', (opttemp) => { var options = prodDiv.querySelectorAll('.s-product-options-option-container') // if (options.length > 1) { // options[1].style = 'display: none' // } var fields = prodDiv.querySelector('salla-product-options'); fields.insertBefore(linksdiv, fields.querySelector('salla-conditional-fields')); }); }); // 4 Pack Black Pack waitForElement('.product-723306792', (prodDiv) => { var linksdiv = document.createElement('div'); linksdiv.classList.add('bundle-options-links'); linksdiv.innerHTML = `

    ${bundleOptionsTitle}

    ${BestSellerText ? `${BestSellerText}` : ''} ${fourPieceOptionDiscount ? `${fourPieceOptionDiscount}%` : ''}
    ${fourPieceOptionTitle}
    ${fourPieceOptionPrice} ${currencyText} ${perPieceText}
    ${freeShippingText ? `${freeShippingText}` : ''} ${eightPieceOptionDiscount ? `${eightPieceOptionDiscount}%` : ''}
    ${eightPieceOptionTitle}
    ${eightPieceOptionPrice} ${currencyText} ${perPieceText}
    ${freeShippingText ? `${freeShippingText}` : ''} ${twelvePieceOptionDiscount ? `${twelvePieceOptionDiscount}%` : ''}
    ${twelvePieceOptionTitle}
    ${twelvePieceOptionPrice} ${currencyText} ${perPieceText}
    `; waitForElement('.s-product-options-option-container', (opttemp) => { var priceDiv = document.querySelector('.pdp-price-div').querySelector('.starting-or-normal-price'); var pricePieceDiv = document.createElement('div'); pricePieceDiv.classList.add('price-piece-div'); // Function to update the original price function updateOriginalPrice() { // Get the current price from the price element var priceText = priceDiv.querySelector('.total-price').textContent.trim(); var priceMatch = priceText.match(/\d+(\.\d+)?/); if (priceMatch) { var currentPrice = parseFloat(priceMatch[0]); // Calculate the original price (assuming 15% discount as per fourPieceOptionDiscount) // var calculatedOriginalPrice = (currentPrice / 0.85).toFixed(0); var calculatedOriginalPrice = (currentPrice / 0.86).toFixed(0); pricePieceDiv.innerHTML = ` ${calculatedOriginalPrice} ${currencyText} `; } } // Initial setup updateOriginalPrice(); priceDiv.appendChild(pricePieceDiv); // Set up observer to watch for price changes var priceElement = priceDiv.querySelector('.total-price'); if (priceElement) { var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.type === 'childList' || mutation.type === 'characterData') { updateOriginalPrice(); } }); }); var observerConfig = { childList: true, characterData: true, subtree: true }; observer.observe(priceElement, observerConfig); } // Continue with the rest of the code var priceDiv2 = document.querySelector('.pdp-price-div'); var pricePieceDiv2 = document.createElement('div'); pricePieceDiv2.classList.add('price-piece-div2'); pricePieceDiv2.innerHTML = ` ${fourPieceOptionPrice} ${currencyText} ${perPieceText} ${perPieceTextNDS} `; priceDiv2.appendChild(pricePieceDiv2); // Observe upsell selection changes and update per-piece price accordingly (function() { var basePerPiecePrice = fourPieceOptionPrice; function updatePerPieceForUpsell() { var isUpsellSelected = !!(prodDiv.querySelector('.size-option-upsell.selected')); var newPriceText = basePerPiecePrice; if (isUpsellSelected) { newPriceText = fourPieceOptionPriceUpsell; } pricePieceDiv2.innerHTML = ` ${newPriceText} ${currencyText} ${perPieceText} ${perPieceTextNDS} `; } updatePerPieceForUpsell(); var upsellContainer = prodDiv.querySelector('.size-option-upsell') ? prodDiv.querySelector('.size-option-upsell').parentElement : null; if (upsellContainer) { upsellContainer.addEventListener('click', function(e) { if (e.target && e.target.closest('.size-option')) { updatePerPieceForUpsell(); } }); var selectionObserver = new MutationObserver(function() { updatePerPieceForUpsell(); }); selectionObserver.observe(upsellContainer, { attributes: true, subtree: true, attributeFilter: ['class'] }); } })(); var options = prodDiv.querySelectorAll('.s-product-options-option-container') // if (options.length > 1) { // options[1].style = 'display: none' // } var fields = prodDiv.querySelector('salla-product-options'); fields.insertBefore(linksdiv, fields.querySelector('salla-conditional-fields')); }); }); // 8 Pack Black Pack waitForElement('.product-2067310458', (prodDiv) => { var linksdiv = document.createElement('div'); linksdiv.classList.add('bundle-options-links'); linksdiv.innerHTML = `

    ${bundleOptionsTitle}

    ${BestSellerText ? `${BestSellerText}` : ''} ${fourPieceOptionDiscount ? `${fourPieceOptionDiscount}%` : ''}
    ${fourPieceOptionTitle}
    ${fourPieceOptionPrice} ${currencyText} ${perPieceText}
    ${freeShippingText ? `${freeShippingText}` : ''} ${eightPieceOptionDiscount ? `${eightPieceOptionDiscount}%` : ''}
    ${eightPieceOptionTitle}
    ${eightPieceOptionPrice} ${currencyText} ${perPieceText}
    ${freeShippingText ? `${freeShippingText}` : ''} ${twelvePieceOptionDiscount ? `${twelvePieceOptionDiscount}%` : ''}
    ${twelvePieceOptionTitle}
    ${twelvePieceOptionPrice} ${currencyText} ${perPieceText}
    `; waitForElement('.s-product-options-option-container', (opttemp) => { var priceDiv = document.querySelector('.pdp-price-div').querySelector('.starting-or-normal-price'); var pricePieceDiv = document.createElement('div'); pricePieceDiv.classList.add('price-piece-div'); // Function to update the original price function updateOriginalPrice() { // Get the current price from the price element var priceText = priceDiv.querySelector('.total-price').textContent.trim(); var priceMatch = priceText.match(/\d+(\.\d+)?/); if (priceMatch) { var currentPrice = parseFloat(priceMatch[0]); // Calculate the original price (assuming 21% discount as per eightPieceOptionDiscount) // // var calculatedOriginalPrice = (currentPrice / 0.79).toFixed(0); // var calculatedOriginalPrice = (currentPrice / 0.79).toFixed(0); var calculatedOriginalPrice = (currentPrice / 0.8).toFixed(0); pricePieceDiv.innerHTML = ` ${calculatedOriginalPrice} ${currencyText} `; } } // Initial setup updateOriginalPrice(); priceDiv.appendChild(pricePieceDiv); // Set up observer to watch for price changes var priceElement = priceDiv.querySelector('.total-price'); if (priceElement) { var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.type === 'childList' || mutation.type === 'characterData') { updateOriginalPrice(); } }); }); var observerConfig = { childList: true, characterData: true, subtree: true }; observer.observe(priceElement, observerConfig); } // Continue with the rest of the code var priceDiv2 = document.querySelector('.pdp-price-div'); var pricePieceDiv2 = document.createElement('div'); pricePieceDiv2.classList.add('price-piece-div2'); pricePieceDiv2.innerHTML = ` ${eightPieceOptionPrice} ${currencyText} ${perPieceText} ${perPieceTextNDS} `; priceDiv2.appendChild(pricePieceDiv2); // Observe upsell selection changes and update per-piece price accordingly (function() { var basePerPiecePrice = eightPieceOptionPrice; function updatePerPieceForUpsell() { var isUpsellSelected = !!(prodDiv.querySelector('.size-option-upsell.selected')); var newPriceText = basePerPiecePrice; if (isUpsellSelected) { newPriceText = eightPieceOptionPriceUpsell; } pricePieceDiv2.innerHTML = ` ${newPriceText} ${currencyText} ${perPieceText} ${perPieceTextNDS} `; } updatePerPieceForUpsell(); var upsellContainer = prodDiv.querySelector('.size-option-upsell') ? prodDiv.querySelector('.size-option-upsell').parentElement : null; if (upsellContainer) { upsellContainer.addEventListener('click', function(e) { if (e.target && e.target.closest('.size-option')) { updatePerPieceForUpsell(); } }); var selectionObserver = new MutationObserver(function() { updatePerPieceForUpsell(); }); selectionObserver.observe(upsellContainer, { attributes: true, subtree: true, attributeFilter: ['class'] }); } })(); var options = prodDiv.querySelectorAll('.s-product-options-option-container') // if (options.length > 1) { // options[1].style = 'display: none' // } var fields = prodDiv.querySelector('salla-product-options'); fields.insertBefore(linksdiv, fields.querySelector('salla-conditional-fields')); }); }); // 8 Pack Mix Pack Test waitForElement('.product-1344181453', (prodDiv) => { var linksdiv = document.createElement('div'); linksdiv.classList.add('bundle-options-links'); linksdiv.innerHTML = `

    ${bundleOptionsTitle}

    ${BestSellerText ? `${BestSellerText}` : ''} ${fourPieceOptionDiscount ? `${fourPieceOptionDiscount}%` : ''}
    ${fourPieceOptionTitle}
    ${fourPieceOptionPrice} ${currencyText} ${perPieceText}
    ${freeShippingText ? `${freeShippingText}` : ''} ${eightPieceOptionDiscount ? `${eightPieceOptionDiscount}%` : ''}
    ${eightPieceOptionTitle}
    ${eightPieceOptionPrice} ${currencyText} ${perPieceText}
    ${freeShippingText ? `${freeShippingText}` : ''} ${twelvePieceOptionDiscount ? `${twelvePieceOptionDiscount}%` : ''}
    ${twelvePieceOptionTitle}
    ${twelvePieceOptionPrice} ${currencyText} ${perPieceText}
    `; waitForElement('.s-product-options-option-container', (opttemp) => { var priceDiv = document.querySelector('.pdp-price-div').querySelector('.starting-or-normal-price'); var pricePieceDiv = document.createElement('div'); pricePieceDiv.classList.add('price-piece-div'); // Function to update the original price function updateOriginalPrice() { // Get the current price from the price element var priceText = priceDiv.querySelector('.total-price').textContent.trim(); var priceMatch = priceText.match(/\d+(\.\d+)?/); if (priceMatch) { var currentPrice = parseFloat(priceMatch[0]); // Calculate the original price (assuming 21% discount as per eightPieceOptionDiscount) // // var calculatedOriginalPrice = (currentPrice / 0.79).toFixed(0); // var calculatedOriginalPrice = (currentPrice / 0.79).toFixed(0); var calculatedOriginalPrice = (currentPrice / 0.8).toFixed(0); pricePieceDiv.innerHTML = ` ${calculatedOriginalPrice} ${currencyText} `; } } // Initial setup updateOriginalPrice(); priceDiv.appendChild(pricePieceDiv); // Set up observer to watch for price changes var priceElement = priceDiv.querySelector('.total-price'); if (priceElement) { var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.type === 'childList' || mutation.type === 'characterData') { updateOriginalPrice(); } }); }); var observerConfig = { childList: true, characterData: true, subtree: true }; observer.observe(priceElement, observerConfig); } // Continue with the rest of the code var priceDiv2 = document.querySelector('.pdp-price-div'); var pricePieceDiv2 = document.createElement('div'); pricePieceDiv2.classList.add('price-piece-div2'); pricePieceDiv2.innerHTML = ` ${eightPieceOptionPrice} ${currencyText} ${perPieceText} ${perPieceTextNDS} `; priceDiv2.appendChild(pricePieceDiv2); // Observe upsell selection changes and update per-piece price accordingly (function() { var basePerPiecePrice = eightPieceOptionPrice; function updatePerPieceForUpsell() { var isUpsellSelected = !!(prodDiv.querySelector('.size-option-upsell.selected')); var newPriceText = basePerPiecePrice; if (isUpsellSelected) { newPriceText = eightPieceOptionPriceUpsell; } pricePieceDiv2.innerHTML = ` ${newPriceText} ${currencyText} ${perPieceText} ${perPieceTextNDS} `; } updatePerPieceForUpsell(); var upsellContainer = prodDiv.querySelector('.size-option-upsell') ? prodDiv.querySelector('.size-option-upsell').parentElement : null; if (upsellContainer) { upsellContainer.addEventListener('click', function(e) { if (e.target && e.target.closest('.size-option')) { updatePerPieceForUpsell(); } }); var selectionObserver = new MutationObserver(function() { updatePerPieceForUpsell(); }); selectionObserver.observe(upsellContainer, { attributes: true, subtree: true, attributeFilter: ['class'] }); } })(); var options = prodDiv.querySelectorAll('.s-product-options-option-container') // if (options.length > 1) { // options[1].style = 'display: none' // } var fields = prodDiv.querySelector('salla-product-options'); fields.insertBefore(linksdiv, fields.querySelector('salla-conditional-fields')); }); }); // 12 Pack Black Pack waitForElement('.product-1727535782', (prodDiv) => { var linksdiv = document.createElement('div'); linksdiv.classList.add('bundle-options-links'); linksdiv.innerHTML = `

    ${bundleOptionsTitle}

    ${BestSellerText ? `${BestSellerText}` : ''} ${fourPieceOptionDiscount ? `${fourPieceOptionDiscount}%` : ''}
    ${fourPieceOptionTitle}
    ${fourPieceOptionPrice} ${currencyText} ${perPieceText}
    ${freeShippingText ? `${freeShippingText}` : ''} ${eightPieceOptionDiscount ? `${eightPieceOptionDiscount}%` : ''}
    ${eightPieceOptionTitle}
    ${eightPieceOptionPrice} ${currencyText} ${perPieceText}
    ${freeShippingText ? `${freeShippingText}` : ''} ${twelvePieceOptionDiscount ? `${twelvePieceOptionDiscount}%` : ''}
    ${twelvePieceOptionTitle}
    ${twelvePieceOptionPrice} ${currencyText} ${perPieceText}
    `; waitForElement('.s-product-options-option-container', (opttemp) => { var priceDiv = document.querySelector('.pdp-price-div').querySelector('.starting-or-normal-price'); var pricePieceDiv = document.createElement('div'); pricePieceDiv.classList.add('price-piece-div'); // Function to update the original price function updateOriginalPrice() { // Get the current price from the price element var priceText = priceDiv.querySelector('.total-price').textContent.trim(); var priceMatch = priceText.match(/\d+(\.\d+)?/); if (priceMatch) { var currentPrice = parseFloat(priceMatch[0]); // Calculate the original price (assuming 29% discount as per twelvePieceOptionDiscount) //var calculatedOriginalPrice = (currentPrice / 0.71).toFixed(0); var calculatedOriginalPrice = (currentPrice / 0.71).toFixed(0); pricePieceDiv.innerHTML = ` ${calculatedOriginalPrice} ${currencyText} `; } } // Initial setup updateOriginalPrice(); priceDiv.appendChild(pricePieceDiv); // Set up observer to watch for price changes var priceElement = priceDiv.querySelector('.total-price'); if (priceElement) { var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.type === 'childList' || mutation.type === 'characterData') { updateOriginalPrice(); } }); }); var observerConfig = { childList: true, characterData: true, subtree: true }; observer.observe(priceElement, observerConfig); } // Continue with the rest of the code var priceDiv2 = document.querySelector('.pdp-price-div'); var pricePieceDiv2 = document.createElement('div'); pricePieceDiv2.classList.add('price-piece-div2'); pricePieceDiv2.innerHTML = ` ${twelvePieceOptionPrice} ${currencyText} ${perPieceText} ${perPieceTextNDS} `; priceDiv2.appendChild(pricePieceDiv2); // Observe upsell selection changes and update per-piece price accordingly (function() { var basePerPiecePrice = twelvePieceOptionPrice; function updatePerPieceForUpsell() { var isUpsellSelected = !!(prodDiv.querySelector('.size-option-upsell.selected')); var newPriceText = basePerPiecePrice; if (isUpsellSelected) { newPriceText = twelvePieceOptionPriceUpsell; } pricePieceDiv2.innerHTML = ` ${newPriceText} ${currencyText} ${perPieceText} ${perPieceTextNDS} `; } updatePerPieceForUpsell(); var upsellContainer = prodDiv.querySelector('.size-option-upsell') ? prodDiv.querySelector('.size-option-upsell').parentElement : null; if (upsellContainer) { upsellContainer.addEventListener('click', function(e) { if (e.target && e.target.closest('.size-option')) { updatePerPieceForUpsell(); } }); var selectionObserver = new MutationObserver(function() { updatePerPieceForUpsell(); }); selectionObserver.observe(upsellContainer, { attributes: true, subtree: true, attributeFilter: ['class'] }); } })(); var options = prodDiv.querySelectorAll('.s-product-options-option-container') // if (options.length > 1) { // options[1].style = 'display: none' // } var fields = prodDiv.querySelector('salla-product-options'); fields.insertBefore(linksdiv, fields.querySelector('salla-conditional-fields')); }); }); /*******************************************************************************************/ /************* Size Guide ****************/ /*******************************************************************************************/ // Add this new function to handle modal event listeners function setupSizeGuideEventListeners(modalOverlay) { // Get the size guide link and close button var sizeGuideLink = document.querySelector('.size-guide-link-div'); var closeButton = modalOverlay.querySelector('.modal-close'); // Show modal when clicking the size guide link sizeGuideLink.addEventListener('click', (e) => { e.preventDefault(); modalOverlay.style.display = 'flex'; }); // Hide modal when clicking the close button closeButton.addEventListener('click', () => { modalOverlay.style.display = 'none'; }); // Hide modal when clicking outside the content modalOverlay.addEventListener('click', (e) => { if (e.target === modalOverlay) { modalOverlay.style.display = 'none'; } }); } /*******************************************************************************************/ /* move video comparison title to top PDP */ /*******************************************************************************************/ waitForElement('.hawa-video-comparison h2', (h2Element) => { if (window.innerWidth < 768) { var flexContainer = h2Element.closest('.flex'); if (flexContainer) { var newH2 = h2Element.cloneNode(true); newH2.classList.add('video-comparison-title-top'); flexContainer.appendChild(newH2); h2Element.remove(); } } else { console.log('Not on mobile'); } }); /*******************************************************************************************/ /*******************************************************************************************/ /*******************************************************************************************/ /*************************** ALL OTHER PAGES CUSTOMIZATION ****************************************/ /*******************************************************************************************/ /*******************************************************************************************/ /*******************************************************************************************/ // FAQ Data Structure var faqDataNonProduct = { en: [ { question: "What is the First Pair Guarantee?", answer: "We're confident that we created the best boxers on the planet. If you don't love your first pair, we will send you a different size or issue a full refund - no return required.", link: "https://hawa.co/en/return-policy/page-1642404213", linkText: 'Guarantee Policy' }, { question: "Do you offer Returns and Exchanges?", answer: "You can return or exchange within 7 days from receiving your order.", link: "https://hawa.co/en/return-policy/page-1642404213", linkText: 'Return Policy' }, { question: "When will my items ship? How long will it take to arrive?", answer: "Saudi Arabia:\n\n•Riyadh: within 48 hours (excluding Friday)\n•Dammam and Jeddah: within 3 days (excluding Friday)\n•Other cities in Saudi Arabia: 3-6 days (excluding Friday)\n\n•Gulf Countries:UAE: within 1 week\n•Kuwait and other GCC countries: within 2 weeks", link: '', linkText: '' } ], ar: [ { question: "وش هو ضمان هوا على البوكسر الأول؟", answer: "واثقين في منتجنا، أخذ مننا فوق السنة من البحث والتطوير. في حال ماعجبك أول بوكسر. أبد خله عندك وترجع لك فلوسك.", link: 'https://hawa.co/ar/return-policy/page-1642404213', linkText: 'للمزيد: سياسة الضمان' }, { question: "هل يمديني أسترجع أو استبدل المنتج؟", answer: "أكيد يمديك، بإمكانك الاسترجاع والاستبدال خلال 30 يوم من استلام الطلب.", link: 'https://hawa.co/ar/return-policy/page-1642404213', linkText: 'للمزيد: سياسة الاستبدال والاسترجاع' }, { question: `كم ياخذ الشحن لمنتجات هوا؟`, answer: `داخل المملكة:\n\n• يتم التوصيل داخل الرياض خلال 48 ساعة (باستثناء يوم الجمعة)\n• باقي مدن المملكة الكبيرة مثل جدة والدمام، خلال 3 أيام عمل (باستثناء يوم الجمعة)\n• باقي مدن المملكة، خلال 6 أيام عمل كحد أقصى (باستثناء يوم الجمعة)\n\nباقي دول الخليج:\n\n• دولة الإمارات: خلال أسبوع\n• دولة الكويت وباقي دول الخليج: خلال أسبوعين`, link: '', linkText: '' } ] }; // NATIONAL DAY PRODUCTS CHANGES HERE if (!document.querySelector('.product-2130693625') && !document.querySelector('.product-271747864') && !document.querySelector('.product-1716601874') && !document.querySelector('.product-1306857438') && !document.querySelector('.cart') && !document.querySelector('.product-727834477') && !document.querySelector('.product-1727535782') && !document.querySelector('.product-723306792') && !document.querySelector('.product-2067310458') && !document.querySelector('.product-50512583') && !document.querySelector('.product-1344181453')) { /*******************************************************************************************/ /* Intagram in all other pages */ /*******************************************************************************************/ var targetDiv = document.querySelector('.store-footer'); var targetElementinstaPDP = document.createElement('div'); if (targetDiv) { if(htmlLang == 'en'){ targetElementinstaPDP.innerHTML= `

    `+instaTextEn+`

    ` } else { targetElementinstaPDP.innerHTML= `

    `+instaTextAr+`

    ` } targetDiv.parentNode.insertBefore(targetElementinstaPDP, targetDiv); } else { console.log('insta element element not found'); } } } /*******************************************************************************************/ /*******************************************************************************************/ /*******************************************************************************************/ /************************************ CART PAGE ************************************/ /*******************************************************************************************/ /*******************************************************************************************/ /*******************************************************************************************/ if (document.querySelector('.cart')) { /*******************************************************************************************/ /* CART Size and Pack Options */ /*******************************************************************************************/ function encapsulateDropdownWithSquares(selectElement) { if (selectElement) { var sizeOptionsContainer = document.createElement('div'); sizeOptionsContainer.classList.add('size-options'); sizeOptionsContainer.classList.add('size-options-cart'); Array.from(selectElement.options).forEach(function(option) { if (option.value !== "") { var sizeOptionDiv = document.createElement('div'); sizeOptionDiv.classList.add('size-option'); sizeOptionDiv.classList.add('size-option-cart'); sizeOptionDiv.textContent = option.textContent.split(' - ')[0]; // Show only the size letter if(option.textContent.includes('بوكسر') || option.textContent.includes('Boxer')){ sizeOptionDiv.classList.add('size-option-upsell'); //console.log(sizeOptionDiv); } if (option.selected) { sizeOptionDiv.classList.add('selected'); } if (option.disabled || option.textContent.includes("Out of Stock") || option.textContent.includes("نفدت الكمية")) { sizeOptionDiv.classList.add('disabled'); } sizeOptionDiv.addEventListener('click', function() { sizeOptionsContainer.querySelectorAll('.size-option').forEach(function(opt) { opt.classList.remove('selected'); }); sizeOptionDiv.classList.add('selected'); selectElement.value = sizeOptionDiv.getAttribute('data-value'); var event = new Event('change', { bubbles: true }); selectElement.dispatchEvent(event); }); sizeOptionDiv.setAttribute('data-value', option.value); sizeOptionsContainer.appendChild(sizeOptionDiv); } }); selectElement.parentNode.insertBefore(sizeOptionsContainer, selectElement); selectElement.style.position = 'absolute'; // selectElement.style.left = '-9999px'; selectElement.style.marginTop = '-7vh'; selectElement.style.opacity = '0'; selectElement.style.height = '0'; selectElement.style.padding = '0'; } } waitForElement('select[name^="options["]', (boxers) => { var selectElements = document.querySelectorAll('select[name^="options["]'); selectElements.forEach(encapsulateDropdownWithSquares); }); waitForElement('.size-option-upsell', (sizeOptionUpsell) => { // var optionUpsellTitleText = htmlLang === 'en' ? 'Add more at a special price' : 'أضف بوكسر بسعر خاص'; // var optionUpsellTitle = document.createElement('div'); // optionUpsellTitle.classList.add('option-upsell-title'); // optionUpsellTitle.innerHTML = `

    `+optionUpsellTitleText+`

    `; // sizeOptionUpsell.parentElement.parentElement.parentElement.insertAdjacentElement('beforebegin', optionUpsellTitle); sizeOptionUpsell.parentElement.firstChild.classList.add('size-option-upsell-no-add'); var sizeOptionUpsellText = sizeOptionUpsell.textContent.split(' ( '); console.log(sizeOptionUpsellText); sizeOptionUpsell.textContent = ''; var div0 = document.createElement('div'); div0.classList.add('badge-container-upsell'); var span0 = document.createElement('span'); span0.classList.add('option-upsell-free-shipping-span'); if(document.querySelector('select[name="options[1414915792]"]')) { span0.appendChild(document.createTextNode(htmlLang === 'en' ? 'Free Shipping' : 'شحن مجاني')); // span0.appendChild(document.createTextNode(htmlLang === 'en' ? 'Special Offer' : 'عرض خاص')); } else{ span0.appendChild(document.createTextNode(htmlLang === 'en' ? 'Special Offer' : 'عرض خاص')); } div0.appendChild(span0); sizeOptionUpsell.appendChild(div0); var span1 = document.createElement('span'); span1.classList.add('upsell-offering-span'); span1.appendChild(document.createTextNode(sizeOptionUpsellText[0])); sizeOptionUpsell.appendChild(span1); var span2 = document.createElement('span'); span2.classList.add('upsell-price-span'); span2.appendChild(document.createTextNode(sizeOptionUpsellText[1])); sizeOptionUpsell.appendChild(span2); }); /*******************************************************************************************/ /* Cart Color Options */ /*******************************************************************************************/ function encapsulateThumbnailOptionsWithColors(thumbnailWrapper) { if (thumbnailWrapper) { var colorOptionsContainer = document.createElement('div'); colorOptionsContainer.classList.add('color-options'); // Create a wrapper for the color options list var colorOptionsList = document.createElement('div'); colorOptionsList.classList.add('color-options-list'); colorOptionsContainer.appendChild(colorOptionsList); var thumbnailOptions = thumbnailWrapper.querySelectorAll('div'); var firstOptionSelected = false; thumbnailOptions.forEach(function(optionDiv) { var radioInput = optionDiv.querySelector('input[type="radio"]'); var label = optionDiv.querySelector('label'); var img = optionDiv.querySelector('img'); var text = optionDiv.querySelector('p'); if (radioInput && label && img && text) { var colorOptionDiv = document.createElement('div'); colorOptionDiv.classList.add('color-option'); // Determine color type based on text content var colorText = text.textContent.trim(); if (colorText.includes('نص') || colorText.includes('mix') || colorText.includes('Mix')) { colorOptionDiv.classList.add('color-mixed'); } else if (colorText.includes('أسود') || colorText.includes('Black') || colorText.includes('black')) { colorOptionDiv.classList.add('color-black'); } else if (colorText.includes('أبيض') || colorText.includes('White') || colorText.includes('white')) { colorOptionDiv.classList.add('color-white'); } // Only add selected state if radio is actually checked (respect platform defaults) if (radioInput.checked) { colorOptionDiv.classList.add('selected'); } // Add disabled state if radio is disabled if (radioInput.disabled) { colorOptionDiv.classList.add('disabled'); } // Create color indicator var colorIndicator = document.createElement('div'); colorIndicator.classList.add('color-indicator'); // Add text label var colorLabel = document.createElement('span'); colorLabel.classList.add('color-label'); colorLabel.textContent = colorText; colorOptionDiv.appendChild(colorIndicator); colorOptionDiv.appendChild(colorLabel); // Add click event to maintain functionality colorOptionDiv.addEventListener('click', function() { // Remove selected from all options colorOptionsList.querySelectorAll('.color-option').forEach(function(opt) { opt.classList.remove('selected'); }); // Add selected to clicked option colorOptionDiv.classList.add('selected'); // Trigger the original radio input radioInput.checked = true; // Trigger the original label click to maintain go-to-slide functionality label.click(); // Dispatch change event var event = new Event('change', { bubbles: true }); radioInput.dispatchEvent(event); }); colorOptionsList.appendChild(colorOptionDiv); } }); // Insert the new container before the original wrapper thumbnailWrapper.parentNode.insertBefore(colorOptionsContainer, thumbnailWrapper); // Hide the original wrapper thumbnailWrapper.style.display = 'none'; } } waitForElement('.s-product-options-thumbnails-wrapper', (firstThumbnailWrapper) => { // Handle all thumbnail wrappers in cart, not just the first one var allThumbnailWrappers = document.querySelectorAll('.s-product-options-thumbnails-wrapper'); allThumbnailWrappers.forEach(function(thumbnailWrapper) { // Check if this wrapper has already been processed if (!thumbnailWrapper.dataset.colorOptionsProcessed) { encapsulateThumbnailOptionsWithColors(thumbnailWrapper); thumbnailWrapper.dataset.colorOptionsProcessed = 'true'; } }); }); /*******************************************************************************************/ /* Reorder Cart Elements */ /*******************************************************************************************/ function isCartPage() { var freeShippingElement = document.querySelector('#free-shipping'); return freeShippingElement; } function reorderCartElements() { // First, verify we're on the cart page if (!isCartPage()) { console.log('Not Cart Page'); return; // Exit if not cart page } // Get main container and elements var mainContainer = document.querySelector('.flex.flex-col.items-start'); var cartContent = document.querySelector('.main-content'); var sidebar = document.querySelector('.sticky.top-24'); var shippingBar = document.querySelector('#free-shipping'); // Double check all required elements exist if (!mainContainer || !cartContent || !sidebar || !shippingBar) { console.log('Required cart elements not found'); return; } function setMobileOrder() { // First, restore all elements to mainContainer to ensure proper ordering mainContainer.innerHTML = ''; // 1. Move shipping bar to the top mainContainer.appendChild(shippingBar); // 2. Move cart content second mainContainer.appendChild(cartContent); // 3. Move remaining sidebar content last mainContainer.appendChild(sidebar); // Apply mobile styles shippingBar.style.width = '100%'; cartContent.style.order = '0'; // Ensure cart content appears in correct order sidebar.style.width = '100%'; sidebar.style.marginTop = '1rem'; // Move shipping bar outside of sidebar in mobile view if (sidebar.contains(shippingBar)) { mainContainer.insertBefore(shippingBar, mainContainer.firstChild); } } function setDesktopOrder() { // Restore original structure if (!sidebar.contains(shippingBar)) { sidebar.insertBefore(shippingBar, sidebar.firstChild); } // Reset styles shippingBar.style.width = ''; cartContent.style.order = ''; sidebar.style.width = ''; sidebar.style.marginTop = ''; // Ensure correct desktop order mainContainer.innerHTML = ''; mainContainer.appendChild(cartContent); mainContainer.appendChild(sidebar); } // Create and observe screen size changes var mediaQuery = window.matchMedia('(max-width: 1023px)'); // matches your lg: breakpoint // Initial check if (mediaQuery.matches) { setMobileOrder(); } else { setDesktopOrder(); } // Listen for screen size changes mediaQuery.addEventListener('change', (e) => { if (e.matches) { setMobileOrder(); } else { setDesktopOrder(); } }); } if (isCartPage()) { reorderCartElements(); } /*******************************************************************************************/ /************* Free Shipping ****************/ /*******************************************************************************************/ var FREE_SHIPPING_THRESHOLD = 280; class FreeShippingBar { constructor() { // DOM Elements this.freeShippingBar = document.getElementById('free-shipping-bar').querySelector('.progress-bg'); this.freeShippingMsg = document.getElementById('free-shipping-msg'); this.freeShippingApplied = document.getElementById('free-shipping-applied'); this.cartTotal = document.querySelector('[data-cart-total]'); this.shippingCost = document.getElementById('shipping-cost'); } // Convert Arabic numbers to English numbers convertArabicToEnglish(str) { var arabicNumbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; return str.replace(/[0-9]/g, match => arabicNumbers.indexOf(match)); } // Extract number from price string (e.g., "207 " -> 207) extractNumber(priceString) { var numberStr = this.convertArabicToEnglish(priceString); return parseFloat(numberStr.replace(/[^\d.-]/g, '')); } // Convert English numbers to Arabic convertEnglishToArabic(num) { var arabicNumbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; return num.toString().replace(/[0-9]/g, match => arabicNumbers[match]); } calculateProgress() { // Get cart total var totalText = this.cartTotal.textContent.replace('٫','.'); console.log(totalText); var total = this.extractNumber(totalText); // Get shipping cost if present let shippingCost = 0; if (this.shippingCost && !this.shippingCost.classList.contains('hidden')) { var shippingText = this.shippingCost.querySelector('b').textContent; shippingCost = this.extractNumber(shippingText); } console.log(total, shippingCost); // Calculate actual total excluding shipping cost var actualTotal = total - shippingCost; console.log(actualTotal); // Calculate progress percentage var progress = Math.min((actualTotal / FREE_SHIPPING_THRESHOLD) * 100, 100); console.log(progress); // Calculate remaining amount var remaining = Math.max(FREE_SHIPPING_THRESHOLD - actualTotal, 0); console.log(remaining); this.updateUI(progress, remaining); } updateUI(progress, remaining) { // Update progress bar this.freeShippingBar.style.width = `${progress}%`; // Update message and emoji if (progress >= 100) { this.freeShippingMsg.innerHTML = document.documentElement.lang === 'ar' ? 'مبروك! جاك شحن مجاني' : 'Congratulations! You have free shipping'; this.freeShippingApplied.classList.remove('hidden'); } else { var remainingFormatted = document.documentElement.lang === 'ar' ? this.convertEnglishToArabic(remaining.toFixed(2)) : remaining.toFixed(2); this.freeShippingMsg.innerHTML = document.documentElement.lang === 'ar' ? `احصل على شحن مجاني عند إضافة ${remainingFormatted} للسلة` : `Get free shipping by adding ${remainingFormatted} to your cart`; this.freeShippingApplied.classList.add('hidden'); } } // Initialize and set up observers init() { // Initial calculation this.calculateProgress(); // Set up MutationObserver to watch for changes in cart total var observer = new MutationObserver(() => this.calculateProgress()); observer.observe(this.cartTotal, { childList: true, characterData: true, subtree: true }); if (this.shippingCost) { observer.observe(this.shippingCost, { childList: true, characterData: true, subtree: true, attributes: true }); } } } console.log('Here at the free shipping bar'); if (isCartPage()) { console.log('Here at the free shipping bar 2'); waitForElement('#free-shipping-bar', (ff) => { var freeShippingBar = new FreeShippingBar(); freeShippingBar.init(); }); } /*******************************************************************************************/ /* Size Calculator in Cart Page */ /*******************************************************************************************/ function createCartSizeCalculatorPrompt() { // Create the prompt element const promptDiv = document.createElement('div'); promptDiv.className = 'cart-size-calculator-prompt'; // Get the text based on language const title = htmlLang === 'en' ? 'Not sure about your size?' : 'مب متأكد من مقاسك؟'; const description = htmlLang === 'en' ? 'Use our size calculator to make sure before you order' : 'استخدم حاسبة المقاس وتأكد قبل الطلب'; const ctaText = htmlLang === 'en' ? 'Calculate My Size' : 'احسب مقاسي'; promptDiv.innerHTML = `

    ${title}

    ${description}

    `; // Insert the element before the store footer const targetDiv = document.querySelector('#free-shipping'); if (targetDiv) { targetDiv.parentNode.insertBefore(promptDiv, targetDiv); // Create and append the modal if it doesn't exist let modalOverlay = document.querySelector('.modal-overlay'); if (!modalOverlay) { modalOverlay = createSizeGuideModal(); document.body.appendChild(modalOverlay); } // Add click event to the CTA button const ctaButton = promptDiv.querySelector('.size-calculator-cta'); ctaButton.addEventListener('click', () => { modalOverlay.style.display = 'flex'; }); // Set up modal close functionality const closeButton = modalOverlay.querySelector('.modal-close'); if (closeButton) { closeButton.addEventListener('click', () => { modalOverlay.style.display = 'none'; }); } // Close modal when clicking outside modalOverlay.addEventListener('click', (e) => { if (e.target === modalOverlay) { modalOverlay.style.display = 'none'; } }); } else { console.log('Footer element not found for size calculator prompt'); } } // Call the function when the cart page is loaded if (isCartPage()) { createCartSizeCalculatorPrompt(); } /*******************************************************************************************/ /* Guarantee in Cart Page */ /*******************************************************************************************/ if (document.querySelector('.cart')) { var guaranteeText = { en: { title: "First Pair Guarantee", description: "If you don't love your first pair, we will send you a different size or issue a full refund - no return required" }, ar: { title: "ضمان على هواك", description: "نضمن لك أول بوكسر في حال ما ناسبك خله عندك واستبدل المقاس أو نرجع لك فلوسك" } }; var language = document.documentElement.lang || 'en'; var text = guaranteeText[language]; var guaranteeDiv = document.createElement('div'); guaranteeDiv.className = 'hawa-guarantee-section'; guaranteeDiv.classList.add('hawa-guarantee-section-homepage'); guaranteeDiv.innerHTML = `

    ${text.title}

    ${text.description}

    `; var targetDiv = document.querySelector('.store-footer'); if (targetDiv) { targetDiv.parentNode.insertBefore(guaranteeDiv, targetDiv); } else { console.log('footer for guarantee in cart element not found'); } } /*******************************************************************************************/ /* FAQ in Cart Page */ /*******************************************************************************************/ var faqDataNonProduct = { en: [ { question: "What is the First Pair Guarantee?", answer: "We're confident that we created the best boxers on the planet. If you don't love your first pair, we will send you a different size or issue a full refund - no return required.", link: "https://hawa.co/en/return-policy/page-1642404213", linkText: 'Guarantee Policy' }, { question: "Do you offer Returns and Exchanges?", answer: "You can return or exchange within 7 days from receiving your order.", link: "https://hawa.co/en/return-policy/page-1642404213", linkText: 'Return Policy' }, { question: "When will my items ship? How long will it take to arrive?", answer: "Saudi Arabia:\n\n•Riyadh: within 48 hours (excluding Friday)\n•Dammam and Jeddah: within 3 days (excluding Friday)\n•Other cities in Saudi Arabia: 3-6 days (excluding Friday)\n\n•Gulf Countries:UAE: within 1 week\n•Kuwait and other GCC countries: within 2 weeks", link: '', linkText: '' } ], ar: [ { question: "وش هو ضمان هوا على البوكسر الأول؟", answer: "واثقين في منتجنا، أخذ مننا فوق السنة من البحث والتطوير. في حال ماعجبك أول بوكسر. أبد خله عندك وترجع لك فلوسك.", link: 'https://hawa.co/ar/return-policy/page-1642404213', linkText: 'للمزيد: سياسة الضمان' }, { question: "هل يمديني أسترجع أو استبدل المنتج؟", answer: "أكيد يمديك، بإمكانك الاسترجاع والاستبدال خلال 30 يوم من استلام الطلب.", link: 'https://hawa.co/ar/return-policy/page-1642404213', linkText: 'للمزيد: سياسة الاستبدال والاسترجاع' }, { question: `كم ياخذ الشحن لمنتجات هوا؟`, answer: `داخل المملكة:\n\n• يتم التوصيل داخل الرياض خلال 48 ساعة (باستثناء يوم الجمعة)\n• باقي مدن المملكة الكبيرة مثل جدة والدمام، خلال 3 أيام عمل (باستثناء يوم الجمعة)\n• باقي مدن المملكة، خلال 6 أيام عمل كحد أقصى (باستثناء يوم الجمعة)\n\nباقي دول الخليج:\n\n• دولة الإمارات: خلال أسبوع\n• دولة الكويت وباقي دول الخليج: خلال أسبوعين`, link: '', linkText: '' } ] }; if (document.querySelector('.cart')) { // Add CSS for FAQ animation const styleEl = document.createElement('style'); styleEl.textContent = ` .single-faq .faq-content { max-height: 0; overflow: hidden; transition: max-height .4s ease-in-out; } .single-faq.open .faq-content { max-height: 1000px; transition: max-height .4s ease-in-out; } `; document.head.appendChild(styleEl); // Create FAQ section var faqDiv = document.createElement('div'); faqDiv.className = 's-block--faq pdp-faq-section'; // Create the container structure let faqHTML = `

    ${htmlLang === "en" ? "FAQs" : "أسئلة عالبال"}

    `; // Get the appropriate language array var currentFAQs = faqDataNonProduct[htmlLang] || faqDataNonProduct.en; // fallback to English if language not found // Generate FAQ items - UPDATED STRUCTURE currentFAQs.forEach(faq => { faqHTML += `

    ${faq.answer}

    ${faq.link ? `${faq.linkText}` : ''}
    `; }); // Close the container structure faqHTML += `
    `; faqDiv.innerHTML = faqHTML; // Add click and touch handlers for the FAQ toggles - UPDATED HANDLERS faqDiv.querySelectorAll('.faq-btn').forEach(button => { // Function to handle both click and touch events const toggleFAQ = (event) => { // Prevent default behavior (important for touch events) event.preventDefault(); const faqItem = button.parentElement; const icon = button.querySelector('i'); const content = faqItem.querySelector('.faq-content'); // Toggle current FAQ if (faqItem.classList.contains('open')) { faqItem.classList.remove('open'); icon.classList.remove('sicon-keyboard_arrow_up'); icon.classList.add('sicon-keyboard_arrow_down'); } else { faqItem.classList.add('open'); icon.classList.remove('sicon-keyboard_arrow_down'); icon.classList.add('sicon-keyboard_arrow_up'); } // Close other FAQs faqDiv.querySelectorAll('.single-faq').forEach(item => { if (item !== faqItem && item.classList.contains('open')) { item.classList.remove('open'); const otherIcon = item.querySelector('i'); otherIcon.classList.remove('sicon-keyboard_arrow_up'); otherIcon.classList.add('sicon-keyboard_arrow_down'); } }); }; // Add both click and touch events button.addEventListener('click', toggleFAQ); button.addEventListener('touchstart', toggleFAQ, {passive: false}); // Make button explicitly clickable/tappable button.style.cursor = 'pointer'; button.setAttribute('role', 'button'); button.setAttribute('tabindex', '0'); }); var targetDiv = document.querySelector('.store-footer'); if (targetDiv) { targetDiv.parentNode.insertBefore(faqDiv, targetDiv); } else { console.log('footer for faq element not found'); } } } /*******************************************************************************************/ /*******************************************************************************************/ /*******************************************************************************************/ /************************************ THANK YOU PAGE ************************************/ /*******************************************************************************************/ /*******************************************************************************************/ /*******************************************************************************************/ if (document.querySelector('.thank-you')) { waitForElement('.thanks-item', (ff) => { document.querySelector('.thank-you').querySelector('.bg-storeBG').querySelector('nav').remove(); document.querySelector('.thank-you').querySelector('.bg-storeBG').querySelector('.bg-storeBG').querySelector('h1').style.fontSize = '1.8rem'; document.querySelector('.thank-you').querySelector('.bg-storeBG').querySelector('.bg-storeBG').querySelector('h1').style.marginTop = '1.5rem'; document.querySelector('.thank-you').querySelector('.bg-storeBG').querySelector('.bg-storeBG').querySelector('img').parentElement.classList.remove('rtl:-scale-x-100'); document.querySelector('.thank-you').querySelector('.bg-storeBG').querySelector('.bg-storeBG').querySelector('img').setAttribute('src','https://d17gg5c5d03gu7.cloudfront.net/thank+yu.png'); }); } });