I'm trying to hide the shipping calculator on my cart page (using jQuery) depending on which shipping method is selected, first on page load, and then when a user selects another method or updates the cart, that would enable / disable new shipping methods but I can't seem to make it work.
My Javascript / jQuery is pretty rusty so I don't know what I'm doing wrong.
The code bellow is what I've tried so far. It does work like I want on page load (= if "free shipping" is selected OR if it's the only available shipping method, the shipping calculator will be hidden.
But then when I choose another shipping method, the shipping calculator won't show up again unless I manually reload the page.
It won't work either if the cart is updated with extra product quantities (by increasing the amount of products directly on the cart page) to reach the minimum amount to have free shipping.
jQuery(document).ready(function() {
if(jQuery("*[id*=free_shipping]").is(':checked') || jQuery("*[id*=free_shipping]").is(':hidden') ){
jQuery(".woocommerce-shipping-calculator").css("display","none");
}
else{
jQuery(".woocommerce-shipping-calculator").css("display","block");
}
});
jQuery("input[type=radio]").click(function() {
if(jQuery("*[id*=free_shipping]").is(':checked')){
jQuery(".woocommerce-shipping-calculator").css("display","none !important");
}
else{
jQuery(".woocommerce-shipping-calculator").css("display","block !important");
}
})
Any help would be highly appreciated !
Thanks