${p.title}
$${p.price.toFixed(2)} per item
${x.quantity}
Cart
Adjust quantities before reviewing the local confirmation step. No payment is processed in this demonstration.
Estimated total
$0.00
$${p.price.toFixed(2)} per item
Your cart is empty. Browse the catalog to choose a learning product.
'; const total = cart.reduce((t, x) => { const p = items.find(y => y.id === x.id); return t + (p ? p.price * x.quantity : 0); }, 0); document.querySelector('#cart-total').textContent = '$' + total.toFixed(2); localStorage.setItem('merivoxCart', JSON.stringify(cart)); }; render(); document.addEventListener('click', e => { if (e.target.dataset.change) { const i = Number(e.target.dataset.change); cart[i].quantity = Math.max(0, cart[i].quantity + Number(e.target.dataset.step)); if (!cart[i].quantity) cart.splice(i, 1); render(); } }); document.getElementById('checkout').onclick = () => { if (cart.length > 0) document.getElementById('confirm-modal').classList.replace('hidden', 'flex'); }; document.getElementById('confirm-close').onclick = () => { document.getElementById('confirm-modal').classList.replace('flex', 'hidden'); cart = []; localStorage.removeItem('merivoxCart'); document.querySelector('#cart-list').innerHTML = 'Your cart is empty. Browse the catalog to choose a learning product.
'; document.querySelector('#cart-total').textContent = '$0.00'; }; });