Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Exclude Certain States from a Specific Shipping Zone in WooCommerce Checkout Page?

Are you shipping only to a limited number of states from a specific country? This customization allows you to exclude certain states from being displayed during the checkout process in WooCommerce.

add_filter( 'woocommerce_states', 'ts_custom_us_states', 10, 1 );
function ts_custom_us_states( $states ) {
    $non_allowed_us_states = array( 'IN', 'CA', 'CO', 'IL'); 
    // 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;
}

Output

If the customer selects the United States as their country, the dropdown field will omit certain states as specified in the code.

Read Related Article: How to Remove All Taxes in WooCommerce for a Minimum Cart Total and Specific Countries?

Are you more focused on local deliveries, restricting shipping to only one state? Then this guide will help you to limit shipping to only one state with WooCommerce.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

4 thoughts on “How to Exclude Certain States from a Specific Shipping Zone in WooCommerce Checkout Page?

  1. Will this remove the given states from ONLY the shipping details area or BOTH the billing details and shipping details areas?

    1. Hi Dylan,
      The code will remove the given states from both the billing and shipping state fields. For targeting any one of these state fields, the hook should be changed.

      1. Do you happen to know how the hook would need to be changed to take the given state out of ONLY the shipping details?

        1. This is the specific hook ‘woocommerce_states_shipping’ to remove the given states only from the shipping state fields.

Leave a Reply to Dylan Cancel reply

Your email address will not be published. Required fields are marked *

Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible.

Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

By using our site, you acknowledge that you have read and understood our Privacy Policy and Terms & Conditions.