woocommerce only selected state with a default state

For one client, they want to sell only Telangana state in India so we need to show only India in countries list and Telangana in states list.

Since we can choose ‘selling locations’ from woocommerce settings, selecting only India was not a problem.

now we need to show only Telangana in states list,
for that, you can use following code
add following code in your theme’s functions.php file

add_filter( 'woocommerce_states', 'custom_woocommerce_states' );
function custom_woocommerce_states( $states ) {
$states['IN'] = array(
'TG' => 'Telangana',
return $states;

Since we have only one state, obviously client wanted to show that state by default in dropdown,
add below code to get that.

add_filter( 'default_checkout_state', 'change_default_checkout_state' );
function change_default_checkout_state() {
return 'TG'; // state code

do you know any other methor or plugin can do it easily? please let me know 🙂

If you sell to multiple countries and want to select a particular country by default, then add following code to functions.php
add_filter( 'default_checkout_country', 'change_default_checkout_country' );
function change_default_checkout_country() {
return 'IN'; // country code

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.