I am trying to use this code for my woocommerce shop so the taxes won't show if the shipping country switzerland is selected. The problem is, that it only works on a page reload.. if the user selects switzerland in the form it does not change immediately.. is there a way it constantly checks if the country is ch?
<?php global $woocommerce;
$county = array('CH');
if ( in_array( $woocommerce->customer->get_shipping_country(), $county ) ) :
echo "<style> .order-tax {display:none;} </style>";
endif;
?>
You need to use jQuery for that
$(document).ready(function(){
$('#billing_country').on('change', function() {
if ($(this).val() == 'CH')
$('.order-tax').css('display', 'none');
else
$('.order-tax').css('display', 'block');
});
});