Polypropylene Hot Tubs

jQuery(document).ready(function($) { console.log('swx'); // Whenever a .wapf-input is selected (or deselected), calculate the total $('.wapf-input').on('change', function() { console.log('change'); // Step 1: Sum selected .wapf-input values with data-wapf-price="300" var sumSelected = 0; $('.wapf-input:checked').each(function() { if($(this).data('wapf-price') === "300") { sumSelected += parseFloat($(this).data('wapf-price')); } }); // Step 2: Get the value from the specified span and remove non-numeric characters var priceSpanValue = $('.woocommerce-Price-amount.amount').text(); var numericValue = parseFloat(priceSpanValue.replace(/[^\d.-]/g, '')); // Step 3: Calculate the total and display it (or use it as needed) var total = sumSelected + numericValue; console.log("Total: £" + total); // You might want to display this total somewhere on the page // $('#someElement').text("Total: £" + total); }); });