Votre panier
Articles dans le panier 0
Chargement...

Chargement du panier...

Recherche

Catégories
Chargement...
Prix
0 XAF 50,000 XAF
Marques
Chargement...
Disponibilité
Chargement...
Chargement...
+
@endsectionty})` : 'Rupture de stock'}

SKU: ${product.sku}

Catégorie: ${product.category.name}

Marque: ${product.brand.name}

`; // Bind events pour la galerie content.querySelectorAll('.product-gallery img').forEach(img => { img.addEventListener('click', () => { document.getElementById('quick-view-main-image').src = img.src; }); }); // Bind events pour la quantité content.querySelector('#qty-minus').addEventListener('click', () => { const input = content.querySelector('#quick-view-quantity'); if (input.value > 1) input.value = parseInt(input.value) - 1; }); content.querySelector('#qty-plus').addEventListener('click', () => { const input = content.querySelector('#quick-view-quantity'); if (input.value < 10) input.value = parseInt(input.value) + 1; }); } renderPagination(pagination) { const container = document.getElementById('pagination-container'); if (pagination.last_page <= 1) { container.innerHTML = ''; return; } let html = ''; container.innerHTML = html; container.querySelectorAll('.page-link').forEach(link => { link.addEventListener('click', (e) => { e.preventDefault(); const page = parseInt(link.dataset.page); if (page && page !== pagination.current_page) { this.currentFilters.page = page; this.loadProducts(); window.scrollTo({ top: 0, behavior: 'smooth' }); } }); }); } updateProductsCount(pagination) { const countElement = document.getElementById('products-count'); countElement.innerHTML = `Affichage ${pagination.from}–${pagination.to} sur ${pagination.total} produits`; } renderActiveFilters(filtersApplied) { const container = document.getElementById('active-filters'); let html = ''; if (filtersApplied.category) { html += `Catégorie: ${filtersApplied.category} `; } if (filtersApplied.brand) { html += `Marque: ${filtersApplied.brand} `; } if (filtersApplied.availability) { html += `Disponibilité: ${filtersApplied.availability} `; } if (filtersApplied.search) { html += `Recherche: "${filtersApplied.search}" `; } if (filtersApplied.min_price || filtersApplied.max_price) { const min = filtersApplied.min_price || 0; const max = filtersApplied.max_price || 'max'; html += `Prix: ${min} - ${max} XAF `; } if (html) { html = 'Filtres actifs:' + html; html += ''; } container.innerHTML = html; container.querySelectorAll('.btn-close').forEach(btn => { btn.addEventListener('click', () => { this.removeFilter(btn.dataset.filter); }); }); } removeFilter(filterType) { switch (filterType) { case 'category': this.currentFilters.category = null; document.querySelectorAll('.category-filter').forEach(el => el.classList.remove('active')); document.querySelector('.category-filter[data-category=""]').classList.add('active'); break; case 'brand': this.currentFilters.brand = null; document.querySelectorAll('.brand-filter').forEach(el => el.classList.remove('active')); document.querySelector('.brand-filter[data-brand=""]').classList.add('active'); break; case 'availability': this.currentFilters.availability = null; document.querySelectorAll('.availability-filter').forEach(el => el.classList.remove('active')); document.querySelector('.availability-filter[data-availability="all"]').classList.add('active'); break; case 'search': this.currentFilters.search = null; document.getElementById('search-input').value = ''; break; case 'price': this.currentFilters.min_price = null; this.currentFilters.max_price = null; if (this.priceSlider) { this.priceSlider.noUiSlider.set([this.priceRange.min, this.priceRange.max]); } break; } this.currentFilters.page = 1; this.loadProducts(); } resetFilters() { this.currentFilters = { category: null, brand: null, min_price: null, max_price: null, availability: null, search: null, sort: 'default', per_page: 12, page: 1 }; document.getElementById('search-input').value = ''; document.getElementById('sort-select').value = 'default'; document.getElementById('per-page-select').value = '12'; document.querySelectorAll('.category-filter').forEach(el => el.classList.remove('active')); document.querySelector('.category-filter[data-category=""]').classList.add('active'); document.querySelectorAll('.brand-filter').forEach(el => el.classList.remove('active')); document.querySelector('.brand-filter[data-brand=""]').classList.add('active'); document.querySelectorAll('.availability-filter').forEach(el => el.classList.remove('active')); document.querySelector('.availability-filter[data-availability="all"]').classList.add('active'); if (this.priceSlider) { this.priceSlider.noUiSlider.set([this.priceRange.min, this.priceRange.max]); } this.loadProducts(); } setViewMode(mode) { const container = document.getElementById('products-container'); const gridBtn = document.getElementById('grid-view'); const listBtn = document.getElementById('list-view'); if (mode === 'grid') { container.className = 'row'; gridBtn.classList.add('active'); listBtn.classList.remove('active'); } else { container.className = 'row list-view'; listBtn.classList.add('active'); gridBtn.classList.remove('active'); } localStorage.setItem('shop-view-mode', mode); } restoreViewMode() { const savedMode = localStorage.getItem('shop-view-mode') || 'grid'; this.setViewMode(savedMode); } showLoading() { document.getElementById('loading-overlay').style.display = 'block'; document.getElementById('products-container').style.opacity = '0.5'; } hideLoading() { document.getElementById('loading-overlay').style.display = 'none'; document.getElementById('products-container').style.opacity = '1'; } showError(message) { const container = document.getElementById('products-container'); container.innerHTML = `
${message}
`; } } // Fonctions globales function addToCart(productId, productName, price) { showLoading('Ajout au panier...'); fetch('https://www.djoralcharm.com/panier/ajouter', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content') }, body: JSON.stringify({ product_id: productId, quantity: 1 }) }) .then(response => response.json()) .then(data => { hideLoading(); if (data.success) { showSuccess(`${productName} ajouté au panier !`); updateCartCount(data.cart_count); } else { showError(data.error || 'Erreur lors de l\'ajout au panier'); } }) .catch(error => { hideLoading(); showError('Erreur de connexion'); console.error('Error:', error); }); } function addToCartFromQuickView(productId, productName, price) { const quantity = parseInt(document.getElementById('quick-view-quantity').value); showLoading('Ajout au panier...'); fetch('https://www.djoralcharm.com/panier/ajouter', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content') }, body: JSON.stringify({ product_id: productId, quantity: quantity }) }) .then(response => response.json()) .then(data => { hideLoading(); if (data.success) { showSuccess(`${productName} (x${quantity}) ajouté au panier !`); updateCartCount(data.cart_count); bootstrap.Modal.getInstance(document.getElementById('quickViewModal')).hide(); } else { showError(data.error || 'Erreur lors de l\'ajout au panier'); } }) .catch(error => { hideLoading(); showError('Erreur de connexion'); console.error('Error:', error); }); } function addToWishlist(productId, productName, price) { const isLoggedIn = false; if (!isLoggedIn) { Swal.fire({ title: 'Connexion requise pour les favoris', text: 'Créez un compte pour sauvegarder vos produits préférés.', icon: 'info', showCancelButton: true, confirmButtonText: 'Créer un compte', cancelButtonText: 'Se connecter', confirmButtonColor: '#3A7D44', cancelButtonColor: '#6c757d' }).then((result) => { if (result.isConfirmed) { window.location.href = 'https://www.djoralcharm.com/inscription'; } else if (result.dismiss === Swal.DismissReason.cancel) { window.location.href = 'https://www.djoralcharm.com/connexion'; } }); return; } showLoading('Ajout aux favoris...'); setTimeout(() => { hideLoading(); showSuccess(`${productName} ajouté aux favoris !`); }, 1000); } // Initialiser le gestionnaire de boutique let shopManager; document.addEventListener('DOMContentLoaded', function() { console.log('DOM loaded, initializing ShopManager...'); // Attendre un peu pour s'assurer que toutes les bibliothèques sont chargées setTimeout(() => { try { // Vérifier que noUiSlider est disponible if (typeof noUiSlider === 'undefined') { console.error('noUiSlider library not loaded'); return; } shopManager = new ShopManager(); console.log('ShopManager initialized successfully'); } catch (error) { console.error('Error initializing ShopManager:', error); } }, 100); });