How to Add State(s) to Countries in WooCommerce

Today we are going to talk about adding state(s) to countries in WooCommerce. You have to paste the following function in your active/child theme’s function.php file.

add_filter('woocommerce_states', 'qaisarsatti_country_states');
function qaisarsatti_country_states( $states ) {
    // If states already exist
    if( isset($states['US'] ) ) {
        $states['AE']['LA'] = __('Los Angeles', 'woocommerce');
    }
    // IF states don't exist for
    else {
        $states['US'] = array(
            'LA' => __('Los Angeles', 'woocommerce'),
        );
    }
    return $states;
}

Qaisar Satti

Hi, I'm Qaisar Satti! I've been a developer for over 20 years, and now I love sharing what I've learned through tutorials and guides. Whether you're working with Magento, PrestaShop, or WooCommerce, my goal is to make your development journey a bit easier and more fun. When I'm not coding or writing, you can find me exploring new tech trends and hanging out with the amazing developer community. Thanks for stopping by, and happy coding!