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.

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

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:

Subscribe
Notify of
4 Comments
Newest
Oldest
Inline Feedbacks
View all comments
Dylan
9 months ago

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

Dylan
8 months ago
Reply to  Saranya

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

4
0
Would love your thoughts, please comment.x
()
x