ما يميزنا
المنتجات الأكتر مبيعاً

Product A
١٩٫٩٩ د.ج

Product B
١٩٫٩٩ د.ج

Product C
١٩٫٩٩ د.ج

Product D
١٩٫٩٩ د.ج
تفاصيل الطلب
سعر التوصيل: 0 دج
// Variables to store dropdown names const nameWilaya = "wilaya"; const nameCommune = "commune"; // Wilaya and Commune data const wilayas = [ "01 ~ أدرار", "02 ~ الشلف", "03 ~ الأغواط", "04 ~ أم البواقي", "05 ~ باتنة", "06 ~ بجاية", "07 ~ بسكرة", "08 ~ بشار", "09 ~ البليدة", "10 ~ البويرة", // Add more wilayas as needed ]; const communes = { "01 ~ أدرار": ["أدرار", "تامست", "شروين", "رقان"], "02 ~ الشلف": ["الشلف", "تنس", "بنايرية", "الكريمية"], "03 ~ الأغواط": ["الأغواط", "قصر الحيران", "بن ناصر بن شهرة"], "04 ~ أم البواقي": ["أم البواقي", "عين البيضاء", "عين مليلة"], "05 ~ باتنة": ["باتنة", "غسيرة", "معافة"], "06 ~ بجاية": ["بجاية", "بوخليفة", "تيشي"], "07 ~ بسكرة": ["بسكرة", "ليوة", "لوطاية"], "08 ~ بشار": ["بشار", "عرق فراج", "مريجة"], "09 ~ البليدة": ["البليدة", "شبلي", "بوينان"], "10 ~ البويرة": ["البويرة", "عين الترك", "ايت لعزيز"], // Add more communes as needed }; // Populate wilaya dropdown function populateWilayaDropdown() { const wilayaDropdown = document.querySelector(`select[name="${nameWilaya}"]`); wilayaDropdown.innerHTML = ""; // Clear existing options wilayas.forEach(wilaya => { const option = document.createElement("option"); option.value = wilaya; option.textContent = wilaya; wilayaDropdown.appendChild(option); }); } // Populate commune dropdown based on selected wilaya function populateCommuneDropdown(selectedWilaya) { const communeDropdown = document.querySelector(`select[name="${nameCommune}"]`); communeDropdown.innerHTML = ""; // Clear existing options if (communes[selectedWilaya]) { communes[selectedWilaya].forEach(commune => { const option = document.createElement("option"); option.value = commune; option.textContent = commune; communeDropdown.appendChild(option); }); } else { const defaultOption = document.createElement("option"); defaultOption.value = ""; defaultOption.textContent = "إختر البلدية"; communeDropdown.appendChild(defaultOption); } } // Update delivery price based on selected wilaya and offer function updateDeliveryPrice() { const selectedOffer = $('input[name="offer"]:checked').val(); const selectedWilaya = $(`select[name="${nameWilaya}"]`).val(); const selectedStopdesk = "التوصيل للمكتب"; // Assuming stop desk is hardcoded let priceText = ""; if (selectedWilaya === "01 ~ أدرار") { if ( selectedOffer === "قطعتين + توصيل مجاني" || selectedOffer === "ثلاث قطع + توصيل مجاني" || selectedOffer === "قطعة واحدة + توصيل مجاني" || selectedOffer === "قطعتين + توصيل مجاني + خصم 100 دج" ) { priceText = "00 دج"; } else if (selectedOffer === selectedStopdesk) { priceText = "800 دج"; } else { priceText = "1400 دج"; } } else if (selectedWilaya === "02 ~ الشلف") { if ( selectedOffer === "قطعتين + توصيل مجاني" || selectedOffer === "ثلاث قطع + توصيل مجاني" || selectedOffer === "قطعة واحدة + توصيل مجاني" || selectedOffer === "قطعتين + توصيل مجاني + خصم 100 دج" ) { priceText = "00 دج"; } else if (selectedOffer === selectedStopdesk) { priceText = "400 دج"; } else { priceText = "700 دج"; } } else { priceText = "اختر الولاية"; } $(".delivery-price").text(priceText); } // Event listeners $(document).ready(function () { populateWilayaDropdown(); $(document).on("change", `select[name="${nameWilaya}"]`, function () { const selectedWilaya = $(this).val(); populateCommuneDropdown(selectedWilaya); updateDeliveryPrice(); }); $(document).on("change", 'input[name="offer"]', function () { updateDeliveryPrice(); }); // Initial call to set default values updateDeliveryPrice(); });