Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 503
R.K.Bhardwaj Avatar asked Dec 10 '18 08:12

R.K.Bhardwaj


Video Answer


1 Answers

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.

like image 114
Gufran Hasan Avatar answered Nov 03 '22 17:11

Gufran Hasan