Remove Specific States of a Country on the WooCommerce Checkout

Quick Summary

  • Filter woocommerce_states and unset the states you don't ship to, such as Hawaii from the United States list.
  • Add one unset line per state, keyed by country and state code; WooCommerce lists all codes in its i18n/states.php file.
  • The change applies to WooCommerce's master list, so the state disappears everywhere that list is used, not only on checkout.

WooCommerce keeps a list of states (and provinces, counties and so on) for each country, and the State dropdown on the checkout is built from it. The woocommerce_states filter lets you change that list before it is used, so you can remove a state you don’t ship to. The example below removes Hawaii from the United States.

Add the code to your child theme’s functions.php file or a small custom plugin.

PHP
/**
 * Modify Woocommerce states array
 *
 * @param array $states, collection of all $states
 * @return array $states, modified array.
*/
add_filter( 'woocommerce_states', function( $states ){
    // Unset Hawaii
    unset( $states['US']['HI'] );

    return $states;
}, 999);

How it works

  • $states is an array keyed by country code, and each country holds its states keyed by state code. $states['US']['HI'] is Hawaii in the United States.
  • To remove more states, add one unset() line for each, with the right country and state code, for example $states['US']['AK'] for Alaska.
  • WooCommerce’s own list of codes is in the i18n/states.php file inside the WooCommerce plugin folder.
  • The priority 999 runs the filter late, after most other code that changes the list.

The filter changes WooCommerce’s master list, so the removed state disappears everywhere WooCommerce shows that list, not only on the checkout. If you want to stop selling to a whole country instead, use the selling location options in WooCommerce > Settings > General. To pre-select a country and state rather than remove one, change the checkout’s default location with a filter.

If your shipping regions need more than a shorter state list, I set up checkout and shipping rules as part of my WooCommerce development work.

Share on X (opens in a new tab) Share on LinkedIn (opens in a new tab) Share on Facebook (opens in a new tab)

ChatGPT (opens in a new tab) Claude (opens in a new tab) Gemini (opens in a new tab) Perplexity (opens in a new tab) Grok (opens in a new tab)

More Insights

See More