Skip to content
Advertisement

Remove default selected state from woocommerce checkout billing shipping fields

I have selected default country from admin end United State, but problem is that the state Oregon is coming as the default selected I want to leave state field not default selected so the customer can free to search and select the state

any suggest: below is the screenshot country is ok but state need empty to type for the customer

https://prnt.sc/lsy6xz

Thanks

Advertisement

Answer

Please put this code in functions.php file.

//default checkout state
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() {
    return ''; //set state code if you want to set it otherwise leave it blank.
}

Note: default_checkout_state filter hook is now deprecated. So Please default_checkout_billing_state and default_checkout_shipping_state hooks to change default state on checkout page.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement