@xue28 that’s a custom code that came with the website, I’ll paste the code here so the issue is JavaScript related when the cart is updated, jQuery can’t get the field value anymore… this is what I am trying to figure out.
<script type="text/javascript">
jQuery( document ).ready(function( $ )
{
var checkbox = myAjax.insurance_opt=='optional' ? '<input type="checkbox" id="optional_s" name="optional_s">':'';
var button_text = myAjax.Policy_text!='' ? myAjax.Policy_text : 'view policy';
var button_color= myAjax.Policy_color!='' ? myAjax.Policy_color : 'red';
var policy_text_visible = 'no';
jQuery('input#shipping_insurance_box').click(function()
{
if(jQuery(this).is(":checked") == 'true'){
var shipping_insurance_box = '1';
}
else if(jQuery(this).is(":not(:checked)")){
var shipping_insurance_box = '0';
}
if(jQuery('.insurance_fee_change').val() == 'forced'){
var shipping_insurance_box = '1';
}
var fee_change = jQuery('select.insurance_fee_change option:selected').val();
jQuery.post('https://96472d1798.nxcli.io/wp-admin/admin-ajax.php',{'action':'add_custom_cart_shipping','shipping_insurance_box':shipping_insurance_box,'fee_change':fee_change},function(response){
jQuery('body').trigger('wc_update_cart');
jQuery('body').trigger('update_checkout');
});
setTimeout(function(){
if(policy_text_visible == "yes"){
jQuery("tr.fee th").append('<span style="color:'+button_color+'" class="Show_Policy" id="insurance_policy">('+button_text+')</span>');
}
}, 1000);
});
jQuery(document).on('change','select.insurance_fee_change',function(){
var fee_change = jQuery('select.insurance_fee_change option:selected').val();
if(fee_change == 'yes'){
jQuery('input#shipping_insurance_box').prop('checked', true).trigger('click');
}
else{
jQuery('input#shipping_insurance_box').prop('checked', false).trigger('click');
}
})
});
</script>