Test Store

Testing 1 2 3

.item, .cart, .checkout-form { margin: 20px 0; padding: 10px; border: 1px solid #ccc; } .hidden { display: none; } label { display: block; margin-top: 10px; }

Item 01

Price: $10

Add to Cart

Item 02

Price: $20

Add to Cart
View Cart
https://cdn.jsdelivr.net/npm/emailjs-com@3/dist/email.min.js emailjs.init(“YOUR_EMAILJS_USER_ID”); // Replace with your EmailJS user ID let cart = []; function addToCart(item, price) { let found = cart.find(i => i.item === item); if (found) { found.qty++; } else { cart.push({ item, price, qty: 1 }); } alert(item + ” added to cart.”); } function showCart() { document.getElementById(“store”).classList.add(“hidden”); document.getElementById(“cart”).classList.remove(“hidden”); let list = cart.map(c => `

${c.item} – $${c.price} x ${c.qty}

`).join(“”); document.getElementById(“cart-items”).innerHTML = list; updateTotal(); } function updateTotal() { let total = cart.reduce((sum, c) => sum + c.price * c.qty, 0); document.getElementById(“total”).innerText = “Total: $” + total.toFixed(2); } function applyPromo() { let code = document.getElementById(“promoCode”).value.trim(); if (code === “DISCOUNT10”) { cart.forEach(c => c.price *= 0.9); alert(“10% discount applied!”); updateTotal(); } else { alert(“Invalid promo code.”); } } function showCheckout() { document.getElementById(“cart”).classList.add(“hidden”); document.getElementById(“checkout”).classList.remove(“hidden”); } document.getElementById(“orderForm”).addEventListener(“submit”, function(e) { e.preventDefault(); let form = e.target; let orderSummary = cart.map(c => `${c.item} x ${c.qty} – $${(c.price * c.qty).toFixed(2)}`).join(“\n”); let total = cart.reduce((sum, c) => sum + c.price * c.qty, 0); orderSummary += `\n\nTotal: $${total.toFixed(2)}`; document.getElementById(“orderSummaryField”).value = orderSummary; emailjs.send(“YOUR_SERVICE_ID”, “YOUR_TEMPLATE_ID”, { name: form.name.value, email: form.email.value, address: form.address.value, order: orderSummary }).then(function() { alert(“Order submitted. You’ll be redirected to payment.”); document.getElementById(“checkout”).classList.add(“hidden”); document.getElementById(“paynow”).classList.remove(“hidden”); }, function(error) { alert(“Failed to send order. Try again.”); console.error(error); }); });