Home » WooCommerce: Sell to One State Only

WooCommerce: Sell to One State Only

by Tutor Aspire

Very similar to the “Limit shipping to one State only“, this time we want to limit the Billing to only one state. An Australian client asked me to limit their sales to the South Australia state, but the same can be applied to US, UK and all the other countries that have states.

WooCommerce State Dropdowns @ Checkout

PHP Snippet: Only Sell to One State – WooCommerce Checkout

/**
 * @snippet       One State Billing @ WooCommerce Checkout
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    WooCommerce 4.6
 * @donate $9     https://www.tutoraspire.com
 */

add_filter( 'woocommerce_states', 'tutoraspire_sell_one_state' );

function tutoraspire_sell_one_state( $states ) {

// Only sell to Australia > South Australia
$states['AU'] = array(
'SA' => __( 'South Australia', 'woocommerce' ),
);

return $states;
}


You may also like