I have written a jquery script. It concatenates instead of adding two values
$(document).on('click','.woocommerce-checkout-review-order input[type="submit"]', function(){
var sum = '';
$('.checkout_ilm select').each(function(){
if(jQuery(this).val()!=''){
sum += Number(jQuery(this).val()); // Or this.innerHTML, this.innerText
}
});
alert(sum);
});
When the values in all the select fields is zero then it concatenates the value instead of adding it. So in this case it gives 00 instead of 0 as a result. I have used parseInt and parseFloat also both working but this conditions returns true with parseInt and parseFloat even sum is equal to zero and ilm_selected has also value zero.
if(sum < ilm_selected || sum==''){
//some code
}
Please help, Thanks in advance.
var sum = '';tovar sum = 0;. This should work for you.