In Woocommerce, I am trying to unset the billing state field for all countries except specific ones on checkout page…
Here is my code:
add_filter( 'woocommerce_checkout_fields','custom_override_default_address_fields' );
function custom_override_default_address_fields($myfields){
global $woocommerce;
$country = $woocommerce->customer->get_billing_country();
if($country !== 'US' || $country !== 'AU' || $country !== 'CA' || $country !== 'GB'){
unset( $myfields['billing']['billing_state'] );
}
return $myfields;
}
But it doesn't work really…
How can I remove billing state field for all countries except specific ones in woocommerce?