Earid

Remove specific states of a country on Woocommerce Checkout

11/11/2021

by Earid

The simplest way is to remove them them using the dedicated filter hook woocommerce_states this way:

add_filter( 'woocommerce_states', 'custom_us_states', 10, 1 );
function custom_us_states( $states ) {
    $non_allowed_us_states = array( 'AK', 'HI', 'AA', 'AE', 'AP'); 

    // Loop through your non allowed us states and remove them
    foreach( $non_allowed_us_states as $state_code ) {
        if( isset($states['US'][$state_code]) )
            unset( $states['US'][$state_code] );
    }
    return $states;
}
Facebook
X
LinkedIn
Email
Pinterest
WhatsApp

Remove specific states of a country on Woocommerce Checkout