I have tried the below code to make the default state for visitors blank, so they have to manually choose it.
I want it to work only for non logged in users, cause I would like the state to be preselected if a registered customer goes to checkout, because probably WooCommerce will have kept his state from when he was registered!
add_filter( 'default_checkout_billing_state', 'change_default_checkout_state' );
add_filter( 'default_checkout_shipping_state', 'change_default_checkout_state' );
function change_default_checkout_state() {
if ( ! is_user_logged_in() && is_checkout() ) {
return ''; //set it to blank.
}
}
Unfortunately the above code works even for logged in users. Any advice?