Review Your Items

SHOPPING CART

Complete your purchase

2 Items in Your Cart

Order Summary

Subtotal 0.00 EGP
Shipping Calculated at checkout
Total 0.00 EGP

Secure checkout

const cartData = [ { id: 1, name: "Elegant Evening Dress", price: 1200.00, quantity: 1, image: "assets/img/p1.jpg", size: "M", color: "Black" }, { id: 2, name: "Luxury Silk Blouse", price: 1100.00, quantity: 2, image: "assets/img/p2.jpg", size: "S", color: "White" } ]; // Recommended products const recommendedData = [ { id: 5, name: "Sophisticated Suit Set", price: 3600.00, originalPrice: 4500.00, image: "assets/img/p2.jpg", badge: "Sale" }, { id: 6, name: "Premium Leather Bag", price: 1800.00, originalPrice: null, image: "assets/img/p3.jpg", badge: "New" }, { id: 7, name: "Tailored Blazer", price: 2200.00, originalPrice: null, image: "assets/img/p1.jpg", badge: null }, { id: 8, name: "Chic Summer Dress", price: 1650.00, originalPrice: null, image: "assets/img/p2.jpg", badge: null } ]; let appliedDiscount = 0; // Function to generate cart item HTML function generateCartItem(item) { return `

${item.name}

${item.size} | ${item.color}

${item.price.toFixed(2)} EGP

Total: ${(item.price * item.quantity).toFixed(2)} EGP

`; } // Function to generate recommended product HTML function generateRecommendedProduct(product) { const badgeHTML = product.badge ? `
${product.badge}
` : ''; const priceHTML = product.originalPrice ? `

${product.originalPrice.toFixed(2)} ${product.price.toFixed(2)} EGP

` : `

${product.price.toFixed(2)} EGP

`; return `
`; } // Function to calculate totals function calculateTotals() { const subtotal = cartData.reduce((sum, item) => sum + (item.price * item.quantity), 0); const discount = subtotal * appliedDiscount; const total = subtotal - discount; document.getElementById('subtotalAmount').textContent = subtotal.toFixed(2) + ' EGP'; document.getElementById('totalAmount').textContent = total.toFixed(2) + ' EGP'; // Shipping will be calculated at checkout if (appliedDiscount > 0) { document.getElementById('discountRow').style.display = 'flex'; document.getElementById('discountAmount').textContent = '-' + discount.toFixed(2) + ' EGP'; } else { document.getElementById('discountRow').style.display = 'none'; } } // Function to render cart function renderCart() { const cartItemsList = document.getElementById('cartItemsList'); const emptyCart = document.getElementById('emptyCart'); const cartContent = document.getElementById('cartContent'); const cartCount = document.getElementById('cartItemCount'); const navCartCount = document.getElementById('cartCount'); if (cartData.length === 0) { cartContent.style.display = 'none'; emptyCart.style.display = 'block'; cartCount.textContent = '0'; navCartCount.textContent = '0'; } else { cartContent.style.display = 'flex'; emptyCart.style.display = 'none'; cartCount.textContent = cartData.length; navCartCount.textContent = cartData.length; cartItemsList.innerHTML = cartData.map(item => generateCartItem(item)).join(''); calculateTotals(); attachEventHandlers(); } if (typeof AOS !== 'undefined') { AOS.refresh(); } } // Function to render recommended products function renderRecommendedProducts() { const recommendedContainer = document.getElementById('recommendedProducts'); recommendedContainer.innerHTML = recommendedData.map(product => generateRecommendedProduct(product)).join(''); } // Function to attach event handlers function attachEventHandlers() { // Remove buttons document.querySelectorAll('.cart-item-remove-card').forEach(btn => { btn.addEventListener('click', function() { const itemId = parseInt(this.dataset.itemId); const index = cartData.findIndex(item => item.id === itemId); if (index > -1) { cartData.splice(index, 1); renderCart(); showNotification('Item removed from cart'); } }); }); // Quantity minus buttons document.querySelectorAll('.qty-minus').forEach(btn => { btn.addEventListener('click', function() { const itemId = parseInt(this.dataset.itemId); const item = cartData.find(item => item.id === itemId); if (item && item.quantity > 1) { item.quantity--; renderCart(); } }); }); // Quantity plus buttons document.querySelectorAll('.qty-plus').forEach(btn => { btn.addEventListener('click', function() { const itemId = parseInt(this.dataset.itemId); const item = cartData.find(item => item.id === itemId); if (item && item.quantity < 99) { item.quantity++; renderCart(); } }); }); } // Function to show notification function showNotification(message) { const notification = document.createElement('div'); notification.className = 'cart-notification'; notification.textContent = message; document.body.appendChild(notification); setTimeout(() => { notification.classList.add('show'); }, 10); setTimeout(() => { notification.classList.remove('show'); setTimeout(() => { document.body.removeChild(notification); }, 300); }, 2500); } // Initialize page document.addEventListener('DOMContentLoaded', function() { renderCart(); renderRecommendedProducts(); // Clear cart button const clearCartBtn = document.getElementById('clearCartBtn'); if (clearCartBtn) { clearCartBtn.addEventListener('click', function() { if (confirm('Are you sure you want to clear your cart?')) { cartData.length = 0; appliedDiscount = 0; renderCart(); showNotification('Cart cleared'); } }); } // Coupon form const couponForm = document.getElementById('couponForm'); if (couponForm) { couponForm.addEventListener('submit', function(e) { e.preventDefault(); const couponCode = document.getElementById('couponCode').value.trim().toUpperCase(); const couponSuccess = document.getElementById('couponSuccess'); const couponError = document.getElementById('couponError'); // Sample coupon codes const validCoupons = { 'SAVE10': 0.10, 'SAVE20': 0.20, 'WELCOME': 0.15 }; if (validCoupons[couponCode]) { appliedDiscount = validCoupons[couponCode]; calculateTotals(); couponSuccess.style.display = 'block'; couponError.style.display = 'none'; showNotification('Coupon applied: ' + (appliedDiscount * 100) + '% off!'); } else { couponSuccess.style.display = 'none'; couponError.style.display = 'block'; } }); } });