+
+
+ name : 'سلامت';
+ $cat_color = 'bg-forest-50 dark:bg-forest-900/30 text-forest-500 dark:text-forest-300';
+ if ( $cat_name === 'دستور پخت' || $cat_name === 'غذا' ) {
+ $cat_color = 'bg-honey-50 dark:bg-honey-900/30 text-honey-400';
+ } elseif ( $cat_name === 'سبک زندگی' ) {
+ $cat_color = 'bg-emerald-50 dark:bg-emerald-900/30 text-emerald-500';
+ }
+ $image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'medium' );
+ $img_src = $image ? $image[0] : 'https://picsum.photos/seed/' . get_the_ID() . '/600/400.jpg';
+ ?>
-
-
-
-
- 'w-full h-full object-cover group-hover:scale-105 transition-transform duration-500' ) ); ?>
-
-
-
-
-
+
+
+
; ?>)
+
-
-
-
-
-
- term_id ) ) . '" class="inline-flex items-center gap-1.5 px-3 py-1 bg-forest-50 dark:bg-forest-900/30 text-forest-500 dark:text-forest-300 rounded-full text-xs font-semibold hover:bg-forest-100 dark:hover:bg-forest-900/50 transition">';
- echo esc_html( $categories[0]->name );
- echo '';
- }
- ?>
+
-
+
+
هنوز مطلبی منتشر نشده است.
+
+
-
-
- 2,
- 'prev_text' => '',
- 'next_text' => '',
- ) );
- ?>
-
-
-
-
-
-
-
-
متأسفانه موردی با این مشخصات پیدا نشد.
-
- بازگشت به خانه
-
-
-
+
+
+ 2,
+ 'prev_text' => '',
+ 'next_text' => '',
+ 'screen_reader_text' => ' ',
+ 'class' => 'flex justify-center gap-2',
+ ) ); ?>
+
-
+
-
\ No newline at end of file
+ response.json())
+ .then(data => {
+ if (data.success) {
+ const p = data.data;
+ const existing = cart.find(x => x.id === p.id);
+ if (existing) { existing.qty++; }
+ else { cart.push({ ...p, qty: 1 }); }
+ updateCartUI();
+ showToast(p.name + ' به سبد خرید اضافه شد', 'success');
+ }
+ })
+ .catch(() => {
+ // اگر Ajax کار نکرد، از دادههای mock استفاده کن
+ const mockProduct = {
+ id: id,
+ name: 'محصول شماره ' + id,
+ price: 100000,
+ img: 'default-product'
+ };
+ const existing = cart.find(x => x.id === mockProduct.id);
+ if (existing) { existing.qty++; }
+ else { cart.push({ ...mockProduct, qty: 1 }); }
+ updateCartUI();
+ showToast(mockProduct.name + ' به سبد خرید اضافه شد', 'success');
+ });
+}
- // ==========================================
- // ۱. مدیریت حالت تاریک (Dark Mode)
- // ==========================================
- function initDarkMode() {
- // بررسی تنظیمات ذخیره شده یا تنظیمات سیستم عامل
- const savedTheme = localStorage.getItem('motayeb-theme');
- if (savedTheme === 'dark') {
- html.classList.add('dark');
- }
+function addToCartDetail(productId) {
+ const qty = parseInt(document.getElementById('product-qty')?.textContent || 1);
+ // از طریق Ajax محصول رو واکشی کن
+ fetch(motayeb_ajax.ajax_url + '?action=get_product_data&id=' + productId + '&nonce=' + motayeb_ajax.nonce)
+ .then(response => response.json())
+ .then(data => {
+ if (data.success) {
+ const p = data.data;
+ const existing = cart.find(x => x.id === p.id);
+ if (existing) { existing.qty += qty; }
+ else { cart.push({ ...p, qty: qty }); }
+ updateCartUI();
+ showToast(p.name + ' به سبد خرید اضافه شد', 'success');
+ }
+ })
+ .catch(() => {
+ // Mock
+ const mockProduct = {
+ id: productId,
+ name: 'محصول شماره ' + productId,
+ price: 100000,
+ img: 'default-product'
+ };
+ const existing = cart.find(x => x.id === mockProduct.id);
+ if (existing) { existing.qty += qty; }
+ else { cart.push({ ...mockProduct, qty: qty }); }
+ updateCartUI();
+ showToast(mockProduct.name + ' به سبد خرید اضافه شد', 'success');
+ });
+}
- // اتصال رویداد به دکمه تغییر تم
- const darkBtn = header ? header.querySelector('button[aria-label="حالت تاریک"]') : null;
- if (darkBtn) {
- darkBtn.addEventListener('click', function () {
- html.classList.toggle('dark');
- const isDark = html.classList.contains('dark');
- localStorage.setItem('motayeb-theme', isDark ? 'dark' : 'light');
- });
- }
- }
+function removeFromCart(id) {
+ cart = cart.filter(x => x.id !== id);
+ updateCartUI();
+}
- // ==========================================
- // ۲. سایه هدر هنگام اسکرول
- // ==========================================
- function initHeaderScroll() {
- if (!header) return;
- window.addEventListener('scroll', function () {
- if (window.scrollY > 50) {
- header.classList.add('shadow-lg');
+function updateCartQty(id, delta) {
+ const item = cart.find(x => x.id === id);
+ if (!item) return;
+ item.qty += delta;
+ if (item.qty <= 0) { removeFromCart(id); return; }
+ updateCartUI();
+}
+
+function updateCartUI() {
+ const count = cart.reduce((s, i) => s + i.qty, 0);
+ const total = cart.reduce((s, i) => s + i.price * i.qty, 0);
+
+ // Badge
+ ['cart-count', 'mobile-cart-count', 'cart-drawer-count'].forEach(id => {
+ const el = document.getElementById(id);
+ if (el) {
+ if (id === 'cart-drawer-count') {
+ el.textContent = count;
} else {
- header.classList.remove('shadow-lg');
+ if (count > 0) { el.textContent = count; el.classList.remove('hidden'); }
+ else { el.classList.add('hidden'); }
}
- }, { passive: true });
- }
+ }
+ });
- // ==========================================
- // ۳. مدیریت پنل جستجو
- // ==========================================
- function initSearchOverlay() {
- const overlay = document.getElementById('search-overlay');
- if (!overlay) return;
+ // Drawer items
+ const listEl = document.getElementById('cart-items-list');
+ const emptyEl = document.getElementById('cart-empty');
+ const footerEl = document.getElementById('cart-drawer-footer');
+
+ if (!listEl) return;
+
+ if (cart.length === 0) {
+ listEl.classList.add('hidden');
+ if (emptyEl) emptyEl.classList.remove('hidden');
+ if (footerEl) footerEl.classList.add('hidden');
+ } else {
+ listEl.classList.remove('hidden');
+ if (emptyEl) emptyEl.classList.add('hidden');
+ if (footerEl) footerEl.classList.remove('hidden');
- const input = overlay.querySelector('.search-field');
- const openBtns = document.querySelectorAll('[aria-label="جستجو"]');
+ const totalEl = document.getElementById('cart-drawer-total');
+ if (totalEl) totalEl.textContent = formatPrice(total) + ' تومان';
- // باز کردن
- openBtns.forEach(function (btn) {
- btn.addEventListener('click', function () {
- overlay.classList.remove('hidden');
- body.style.overflow = 'hidden'; // قفل اسکرول
- setTimeout(function () { if (input) input.focus(); }, 150);
- });
- });
-
- // بستن با کلیک روی بکدراپ
- overlay.addEventListener('click', function (e) {
- if (e.target === overlay) {
- closeSearch();
- }
- });
+ listEl.innerHTML = cart.map(i => `
+
+

+
+
${i.name}
+
${formatPrice(i.price)} تومان
+
+
+
+ `).join('');
}
- function closeSearch() {
- const overlay = document.getElementById('search-overlay');
- if (overlay) {
- overlay.classList.add('hidden');
- body.style.overflow = ''; // آزاد کردن اسکرول
- }
- }
-
- // ==========================================
- // ۴. مدیریت منوی موبایل
- // ==========================================
- function initMobileMenu() {
- const menu = document.getElementById('mobile-menu');
- if (!menu) return;
-
- // پیدا کردن دکمه همبرگرری
- const openBtn = header ? header.querySelector('button[aria-label="منوی موبایل"]') : null;
-
- // پیدا کردن دکمه ضربدر داخل منو و بکدراپ
- const closeBtn = menu.querySelector('button');
- const backdrop = menu.querySelector('.absolute.inset-0');
-
- if (openBtn) {
- openBtn.addEventListener('click', function () {
- menu.classList.remove('hidden');
- body.style.overflow = 'hidden';
- });
- }
-
- if (closeBtn) {
- closeBtn.addEventListener('click', closeMobileMenu);
- }
- if (backdrop) {
- backdrop.addEventListener('click', closeMobileMenu);
- }
- }
-
- function closeMobileMenu() {
- const menu = document.getElementById('mobile-menu');
- if (menu) {
- menu.classList.add('hidden');
- body.style.overflow = '';
- }
- }
-
- // ==========================================
- // ۵. میانبرهای کیبورد
- // ==========================================
- function initKeyboardShortcuts() {
- document.addEventListener('keydown', function (e) {
- // بستن با Escape
- if (e.key === 'Escape') {
- closeSearch();
- closeMobileMenu();
- }
- // باز کردن جستجو با Ctrl+K
- if ((e.metaKey || e.ctrlKey) && e.key === 'k') {
- e.preventDefault();
- const overlay = document.getElementById('search-overlay');
- if (overlay) {
- overlay.classList.toggle('hidden');
- if (!overlay.classList.contains('hidden')) {
- body.style.overflow = 'hidden';
- setTimeout(function () {
- const input = overlay.querySelector('.search-field');
- if (input) input.focus();
- }, 150);
- } else {
- body.style.overflow = '';
- }
- }
- }
- });
- }
-
- // ==========================================
- // ۶. اسکرول نرم برای لینکهای #
- // ==========================================
- function initSmoothScroll() {
- document.querySelectorAll('a[href^="#"]:not([href="#"])').forEach(function (anchor) {
- anchor.addEventListener('click', function (e) {
- const targetId = this.getAttribute('href');
- const targetElement = document.querySelector(targetId);
-
- if (targetElement) {
- e.preventDefault();
- closeMobileMenu(); // بستن منو اگر باز بود
-
- const headerHeight = header ? header.offsetHeight : 0;
- const elementPosition = targetElement.getBoundingClientRect().top + window.pageYOffset;
- const offsetPosition = elementPosition - headerHeight - 20;
-
- window.scrollTo({
- top: offsetPosition,
- behavior: 'smooth'
- });
- }
- });
- });
- }
-
- // ==========================================
- // ۷. انیمیشن هنگام اسکرول (Scroll Reveal)
- // ==========================================
- function initScrollAnimations() {
- const elements = document.querySelectorAll('.animate-slide-up, .animate-fade-in');
- if (elements.length === 0) return;
-
- // مخفی کردن اولیه
- elements.forEach(function (el) {
- el.style.opacity = '0';
- el.style.transform = 'translateY(30px)';
- el.style.transition = 'opacity 0.7s cubic-bezier(0.5, 0, 0, 1), transform 0.7s cubic-bezier(0.5, 0, 0, 1)';
- });
-
- const observer = new IntersectionObserver(function (entries) {
- entries.forEach(function (entry) {
- if (entry.isIntersecting) {
- entry.target.style.opacity = '1';
- entry.target.style.transform = 'translateY(0)';
- observer.unobserve(entry.target); // توقف مشاهده پس از اجرا
- }
- });
- }, {
- threshold: 0.1,
- rootMargin: '0px 0px -40px 0px'
- });
-
- elements.forEach(function (el) {
- observer.observe(el);
- });
- }
-
- // ==========================================
- // ۸. سیستم توست (برای استفاده در ووکامرس بعداً)
- // ==========================================
- window.motayebToast = function (message, type) {
- type = type || 'success';
-
- // حذف توست قبلی اگر وجود داشت
- const existingToast = document.querySelector('.motayeb-toast-notification');
- if (existingToast) existingToast.remove();
-
- var toast = document.createElement('div');
- toast.className = 'motayeb-toast-notification fixed top-24 left-1/2 -translate-x-1/2 z-[100] px-6 py-3 rounded-2xl shadow-2xl text-sm font-semibold text-white flex items-center gap-2 transition-all duration-300';
-
- // تنظیم رنگ و آیکون
- if (type === 'success') {
- toast.style.backgroundColor = '#2D5F3F';
- toast.innerHTML = '
' + message;
- } else if (type === 'error') {
- toast.style.backgroundColor = '#dc2626';
- toast.innerHTML = '
' + message;
+ // Checkout
+ const checkoutItems = document.getElementById('checkout-items');
+ if (checkoutItems) {
+ if (cart.length === 0) {
+ checkoutItems.innerHTML = '
سبد خرید خالی است
';
} else {
- toast.style.backgroundColor = '#8B5A3C';
- toast.innerHTML = '
' + message;
+ checkoutItems.innerHTML = cart.map(i => `
+
+

+
+
${i.name}
+
${i.qty} عدد
+
+
${formatPrice(i.price * i.qty)}
+
+ `).join('');
}
+ const subtotalEl = document.getElementById('checkout-subtotal');
+ const totalEl = document.getElementById('checkout-total');
+ if (subtotalEl) subtotalEl.textContent = formatPrice(total) + ' تومان';
+ if (totalEl) totalEl.textContent = formatPrice(total) + ' تومان';
+ }
+}
- // حالت اولیه (مخفی بالای صفحه)
- toast.style.opacity = '0';
- toast.style.transform = 'translate(-50%, -20px)';
-
- body.appendChild(toast);
+function formatPrice(n) {
+ return n.toLocaleString('fa-IR');
+}
- // انیمیشن ورود
- requestAnimationFrame(function () {
- toast.style.opacity = '1';
- toast.style.transform = 'translate(-50%, 0)';
+// ============================================
+// توابع UI
+// ============================================
+function openSearch() {
+ const overlay = document.getElementById('search-overlay');
+ if (overlay) {
+ overlay.classList.remove('hidden');
+ setTimeout(() => {
+ const input = document.getElementById('search-input');
+ if (input) input.focus();
+ }, 100);
+ }
+}
+
+function closeSearch() {
+ const overlay = document.getElementById('search-overlay');
+ if (overlay) overlay.classList.add('hidden');
+ const input = document.getElementById('search-input');
+ if (input) input.value = '';
+ const results = document.getElementById('search-results');
+ if (results) results.innerHTML = '';
+ const suggestions = document.getElementById('search-suggestions');
+ if (suggestions) suggestions.classList.remove('hidden');
+}
+
+function openCart() {
+ const drawer = document.getElementById('cart-drawer');
+ if (drawer) drawer.classList.remove('hidden');
+}
+
+function closeCart() {
+ const drawer = document.getElementById('cart-drawer');
+ if (drawer) drawer.classList.add('hidden');
+}
+
+function openMobileMenu() {
+ const menu = document.getElementById('mobile-menu');
+ if (menu) menu.classList.remove('hidden');
+}
+
+function closeMobileMenu() {
+ const menu = document.getElementById('mobile-menu');
+ if (menu) menu.classList.add('hidden');
+}
+
+function toggleDark() {
+ document.documentElement.classList.toggle('dark');
+}
+
+function toggleLang() {
+ showToast('نسخه انگلیسی به زودی اضافه میشود', 'info');
+}
+
+function goToCheckout() {
+ closeCart();
+ // هدایت به صفحه تسویه حساب ووکامرس
+ if (typeof motayeb_ajax !== 'undefined' && motayeb_ajax.checkout_url) {
+ window.location.href = motayeb_ajax.checkout_url;
+ } else {
+ // Fallback: اگر متغیر وجود نداشت، به صفحه سبد خرید برود
+ window.location.href = '/cart/';
+ }
+}
+
+// ============================================
+// جستجو
+// ============================================
+function handleSearch(val) {
+ const results = document.getElementById('search-results');
+ const suggestions = document.getElementById('search-suggestions');
+ if (!results) return;
+
+ if (val.length < 2) {
+ results.innerHTML = '';
+ if (suggestions) suggestions.classList.remove('hidden');
+ return;
+ }
+ if (suggestions) suggestions.classList.add('hidden');
+
+ // ارسال درخواست Ajax برای جستجو
+ fetch(motayeb_ajax.ajax_url + '?action=search_products&term=' + encodeURIComponent(val) + '&nonce=' + motayeb_ajax.nonce)
+ .then(response => response.json())
+ .then(data => {
+ if (data.success && data.data.length > 0) {
+ results.innerHTML = data.data.map(p => `
+
+ `).join('');
+ } else {
+ results.innerHTML = '
محصولی یافت نشد
';
+ }
+ })
+ .catch(() => {
+ // Mock results
+ results.innerHTML = '
خطا در جستجو. لطفاً دوباره تلاش کنید.
';
});
+}
- // حذف خودکار
- setTimeout(function () {
- toast.style.opacity = '0';
- toast.style.transform = 'translate(-50%, -20px)';
- setTimeout(function () { toast.remove(); }, 300);
- }, 3000);
- };
-
-
- // ==========================================
- // اجرای تمام توابع
- // ==========================================
- initDarkMode();
- initHeaderScroll();
- initSearchOverlay();
- initMobileMenu();
- initKeyboardShortcuts();
- initSmoothScroll();
- initScrollAnimations();
-
- // ==========================================
- // ۹. تعویض عکس در صفحه محصول
- // ==========================================
- window.changeProductImage = function (btn, imgUrl) {
- // تغییر عکس اصلی
- const mainImg = document.getElementById('main-product-image');
- if (mainImg) {
- mainImg.src = imgUrl;
- mainImg.setAttribute('data-large_image', imgUrl);
- }
-
- // تغییر کلاس فعال تامبنیلها
- document.querySelectorAll('.gallery-thumb').forEach(function (thumb) {
- thumb.classList.remove('active');
- thumb.style.borderColor = '';
- });
- btn.classList.add('active');
- };
-
- // ==========================================
- // ۱۰. ستارههای امتیازدهی سفارشی
- // ==========================================
- const starsContainer = document.getElementById('custom-star-rating');
- const ratingInput = document.getElementById('rating');
- if (starsContainer && ratingInput) {
- const stars = starsContainer.querySelectorAll('.star');
-
- stars.forEach(star => {
- star.addEventListener('mouseenter', function() {
- const val = this.dataset.value;
- stars.forEach(s => {
- s.style.color = s.dataset.value <= val ? '#D4A574' : '';
- });
- });
-
- star.addEventListener('click', function() {
- ratingInput.value = this.dataset.value;
- stars.forEach(s => s.classList.remove('active'));
- this.classList.add('active');
- // رنگ دادن به همه ستارههای تا اون عدد
- const val = this.dataset.value;
- stars.forEach(s => {
- if(s.dataset.value <= val) s.classList.add('active');
- });
- });
- });
-
- starsContainer.addEventListener('mouseleave', function() {
- const currentVal = ratingInput.value;
- stars.forEach(s => {
- s.style.color = s.dataset.value <= currentVal ? '#D4A574' : '';
- });
- });
+//زوم تصویر
+function changeImage(src, btn) {
+ const mainImg = document.getElementById('main-product-img');
+ if (!mainImg) return;
+
+ // 1. تغییر تصویر اصلی
+ mainImg.src = src;
+
+ // 2. آپدیت ویژگیهای ضروری برای زوم و پاپآپ ووکامرس
+ mainImg.setAttribute('data-large_image', src);
+ mainImg.setAttribute('data-src', src);
+
+ // 3. مهمترین بخش برای پاپآپ: آپدیت لینک والد (
اطراف عکس)
+ // ووکامرس برای باز کردن پاپآپ از روی href این لینک استفاده میکند
+ const parentLink = mainImg.closest('a');
+ if (parentLink) {
+ parentLink.href = src;
}
+ // 4. بروزرسانی کلاس فعال روی thumbnails
+ document.querySelectorAll('.gallery-thumb').forEach(t => t.classList.remove('active'));
+ if (btn) btn.classList.add('active');
+
+ // 5. بازسازی مجدد Zoom (با متد مقاومتر)
+ if (typeof jQuery !== 'undefined' && typeof jQuery.fn.zoom !== 'undefined') {
+ const $mainImg = jQuery(mainImg);
+ // والد بلافصل عکس را هدف قرار میدهیم (معمولاً یک یا
است)
+ const $wrapper = $mainImg.parent();
+
+ // اگر والد قبلاً زوم داشته باشد، آن را نابود کن
+ $wrapper.trigger('zoom.destroy');
+
+ // زوم جدید را روی والد اعمال کن
+ $wrapper.zoom({
+ url: src,
+ touch: false
+ });
+ }
+}
+
+function selectWeight(btn, price) {
+ document.querySelectorAll('.weight-btn').forEach(b => {
+ b.classList.remove('active', 'border-forest-500', 'dark:border-forest-300', 'bg-forest-50', 'dark:bg-forest-900/30', 'text-forest-500', 'dark:text-forest-300');
+ b.classList.add('border-cream-200', 'dark:border-dark-border');
+ });
+ btn.classList.add('active', 'border-forest-500', 'dark:border-forest-300', 'bg-forest-50', 'dark:bg-forest-900/30', 'text-forest-500', 'dark:text-forest-300');
+ btn.classList.remove('border-cream-200', 'dark:border-dark-border');
+ selectedWeightPrice = price;
+ const priceEl = document.getElementById('product-price');
+ if (priceEl) priceEl.textContent = formatPrice(price);
+}
+
+function changeQty(delta) {
+ const el = document.getElementById('product-qty');
+ if (!el) return;
+ let val = parseInt(el.textContent) + delta;
+ if (val < 1) val = 1;
+ if (val > 10) val = 10;
+ el.textContent = val;
+}
+
+function switchTab(tabId, btn) {
+ document.querySelectorAll('.tab-content').forEach(t => t.classList.add('hidden'));
+ document.querySelectorAll('.tab-btn').forEach(b => {
+ b.classList.remove('tab-active');
+ b.classList.add('text-cream-500', 'dark:text-dark-muted');
+ });
+ const target = document.getElementById('tab-' + tabId);
+ if (target) target.classList.remove('hidden');
+ if (btn) {
+ btn.classList.add('tab-active');
+ btn.classList.remove('text-cream-500', 'dark:text-dark-muted');
+ }
+}
+
+// ============================================
+// علاقهمندیها
+// ============================================
+function toggleWishlist(btn) {
+ const icon = btn.querySelector('iconify-icon');
+ if (!icon) return;
+ const currentIcon = icon.getAttribute('icon');
+ if (currentIcon === 'lucide:heart') {
+ icon.setAttribute('icon', 'lucide:heart');
+ icon.style.color = '#ef4444';
+ icon.style.fill = '#ef4444';
+ showToast('به علاقهمندیها اضافه شد', 'info');
+ } else {
+ icon.style.color = '';
+ icon.style.fill = '';
+ showToast('از علاقهمندیها حذف شد', 'info');
+ }
+}
+
+// ============================================
+// Toast
+// ============================================
+function showToast(msg, type = 'info') {
+ const container = document.getElementById('toast-container');
+ if (!container) return;
+ const colors = { success: 'bg-forest-500', info: 'bg-earth-400', error: 'bg-red-500' };
+ const icons = { success: 'lucide:check-circle', info: 'lucide:info', error: 'lucide:alert-circle' };
+ const toast = document.createElement('div');
+ toast.className = `toast flex items-center gap-3 px-5 py-3 ${colors[type] || 'bg-earth-400'} text-white rounded-2xl shadow-xl text-sm font-medium`;
+ toast.innerHTML = `${msg}`;
+ container.appendChild(toast);
+ setTimeout(() => {
+ toast.style.opacity = '0';
+ toast.style.transition = 'opacity 0.3s';
+ setTimeout(() => toast.remove(), 300);
+ }, 3000);
+}
+
+// ============================================
+// فرمها
+// ============================================
+function handleNewsletter(e) {
+ e.preventDefault();
+ const email = document.getElementById('newsletter-email');
+ if (email) {
+ showToast(email.value + ' با موفقیت ثبت شد!', 'success');
+ email.value = '';
+ }
+}
+
+function handleContact(e) {
+ e.preventDefault();
+ showToast('پیام شما با موفقیت ارسال شد. به زودی پاسخ میدهیم.', 'success');
+ e.target.reset();
+}
+
+// ============================================
+// رویدادهای صفحه کلید
+// ============================================
+document.addEventListener('keydown', function(e) {
+ if (e.key === 'Escape') {
+ closeSearch();
+ closeCart();
+ closeMobileMenu();
+ }
+ if ((e.metaKey || e.ctrlKey) && e.key === 'k') {
+ e.preventDefault();
+ openSearch();
+ }
+});
+
+// ============================================
+// تغییر هدر هنگام اسکرول
+// ============================================
+let lastScroll = 0;
+window.addEventListener('scroll', function() {
+ const header = document.getElementById('header');
+ if (!header) return;
+ const scroll = window.scrollY;
+ if (scroll > 100) {
+ header.classList.add('shadow-lg');
+ } else {
+ header.classList.remove('shadow-lg');
+ }
+ lastScroll = scroll;
+});
+
+// ============================================
+// مقداردهی اولیه
+// ============================================
+document.addEventListener('DOMContentLoaded', function() {
+ // تنظیم شمارنده سبد خرید از کوکی (اختیاری)
+ updateCartUI();
+
+ // اگر در صفحه محصول هستیم، کلاسهای گالری رو تنظیم کن
+ const mainImg = document.getElementById('main-product-img');
+ if (mainImg) {
+ // اولین تصویر گالری رو بهعنوان active تنظیم کن
+ const firstThumb = document.querySelector('.gallery-thumb');
+ if (firstThumb) firstThumb.classList.add('active');
+ }
+});
+
+// نمونه کد جایگزین برای تولید ستاره
+function renderStars(rating) {
+ // ⚠️ اینجا را تغییر دهید: به جای 'ستاره_کانتینر_آیدی'، شناسه واقعی تگ div در HTML خود را بگذارید
+ const container = document.getElementById('star-rating'); // یا هر شناسهای که در HTML دارید
+ if (!container) return; // اگر ظرف پیدا نشد، کد متوقف شود تا خطا ندهد
+
+ container.innerHTML = ''; // پاک کردن ظرف
+
+ for (let i = 1; i <= 5; i++) {
+ let star = document.createElement('i'); // ساختن تگ آیکون
+ if (i <= rating) {
+ star.className = 'fa-solid fa-star text-warning'; // ستاره پر طلایی
+ } else {
+ star.className = 'fa-regular fa-star text-secondary'; // ستاره خالی خاکستری
+ }
+ // اضافه کردن کلیک برای ثبت نظر
+ star.onclick = function() { setRating(i); };
+
+ container.appendChild(star);
+ }
+}
+
+document.addEventListener('DOMContentLoaded', function() {
+ // فرض کنید امتیاز فعلی محصول 0 است یا از دیتابیس میخوانید
+ let initialRating = 0; // یا عددی که از سمت سرور به جاوا اسکریپت پاس داده میشود
+
+ // اگر در صفحه جزئیات نظر هستیم، تابع ستارهها را صدا بزنیم
+ const starContainer = document.getElementById('star-rating'); // همان شناسه بالا
+ if (starContainer) {
+ renderStars(initialRating);
+ }
});
\ No newline at end of file
diff --git a/assets/js/woocommerce.js b/assets/js/woocommerce.js
new file mode 100644
index 0000000..e69de29
diff --git a/comments.php b/comments.php
index 7de320f..55f2f23 100644
--- a/comments.php
+++ b/comments.php
@@ -6,4 +6,4 @@ wp_list_comments(array(
'avatar_size' => 48,
'max_depth' => 3,
));
-?>
\ No newline at end of file
+
diff --git a/footer.php b/footer.php
index f9b4713..06ba22c 100644
--- a/footer.php
+++ b/footer.php
@@ -1,95 +1,120 @@
-
-
-
+
+
+
+
+
+
+
+
+