This is a workaround to Limit Shipping and Billing to One State Only. In two of my previous posts (Limit Shipping to One State Only and Limit Billing to One State Only) we’ve seen similar functionalities. In this case, let’s imagine we want to avoid that the user selects unwanted states.

Remove Unwanted States from the Dropdowns (including the “shipping calculator”) – WooCommerce

WooCommerce State Dropdowns @ Checkout
WooCommerce State Dropdowns @ Checkout WooCommerce State Dropdowns @ Checkout
WooCommerce State Dropdown @ Cart Shipping Calculator
WooCommerce State Dropdown @ Cart Shipping Calculator WooCommerce State Dropdown @ Cart Shipping Calculator

Limit State Dropdowns to One State Only – WooCommerce


// Only one state e.g. PA in US

add_filter( 'woocommerce_states', 'bbloomer_custom_woocommerce_states' );

function bbloomer_custom_woocommerce_states( $states ) {
$states['US'] = array(
'PA' => 'Pennsylvania',
);
return $states;
}

Share:

Leave a Reply