Skip to content
- Choosing a selection results in a full page refresh.
- Opens in a new window.
document.addEventListener('DOMContentLoaded', function() {
const checkboxes = document.querySelectorAll('#add-ons input[type="checkbox"]');
const priceElement = document.querySelector('.product-price'); // Adjust selector to match your theme
let basePrice = parseFloat(priceElement.dataset.basePrice); // Add base price as a data attribute
checkboxes.forEach(checkbox => {
checkbox.addEventListener('change', () => {
let additionalCost = 0;
checkboxes.forEach(cb => {
if (cb.checked) {
additionalCost += parseFloat(cb.value);
}
});
priceElement.textContent = `$${(basePrice + additionalCost).toFixed(2)}`;
});
});
});