{
const updateCartSummary = () => {
const card1 = elementArg.querySelector('#headphones-qty') as any;
const card2 = elementArg.querySelector('#mouse-qty') as any;
const card3 = elementArg.querySelector('#keyboard-qty') as any;
const qty1 = card1?.quantity || 0;
const qty2 = card2?.quantity || 0;
const qty3 = card3?.quantity || 0;
const price1 = 349.99 * qty1;
const price2 = 99.99 * qty2;
const price3 = 79.99 * qty3;
const total = price1 + price2 + price3;
const summary = elementArg.querySelector('#cart-summary-content');
if (summary) {
summary.innerHTML = `
${qty1 > 0 ? `
Sony WH-1000XM5 (${qty1})
$${price1.toFixed(2)}
` : ''}
${qty2 > 0 ? `
Logitech MX Master 3S (${qty2})
$${price2.toFixed(2)}
` : ''}
${qty3 > 0 ? `
Keychron K2 (${qty3})
$${price3.toFixed(2)}
` : ''}
${total === 0 ? 'Your cart is empty
' : ''}
Total
$${total.toFixed(2)}
`;
}
};
// Initial update
setTimeout(updateCartSummary, 100);
// Set up listeners
elementArg.querySelectorAll('dees-shopping-productcard').forEach(card => {
card.addEventListener('quantityChange', updateCartSummary);
});
}}>