How to set a default country in the checkout form in WooCommerce
How to set a default country in the checkout form in WooCommerce

For most small and medium online stores, most of the orders come from a single country. In such cases, it is a good idea to set a default country in the checkout form and billing form. It helps most of your customers to get through the checkout process quickly.
In this blog, we show you how to set a country as the default country on the WooCommerce checkout page.
Step 1: Log in to WordPress admin dashboard
Step 2: Go to Appearance > Theme Editor to open the WordPress Theme Editor
Step 3: Open the functions.php file
Select functions.php file from the list of files on the right side of the screen to open it on the text editor in the middle of the screen.
Step 4: Copy the following PHP code snippet
/**
* Change the default country on the checkout page
*/
add_filter( 'default_checkout_billing_country', 'change_default_checkout_country' );
function change_default_checkout_country() {
return 'US'; // Put Country code here
}
The above code will set the default country to US in the checkout form. You can change this to any other country you wish. We will show you how to do it later.
Step 5: Add the code snippet to functions.php
Now go to the WordPress Theme Editor where you have the functions.php file opened right now.
Click anywhere on the code and scroll down to the bottom of the file.
Paste the above code snippet at the end of the functions.php file.
How to change the country alpha code
As we said earlier, the above code set US as the default country. If you want to set any other country as the default country, all you need to do is replace the alpha country code of US to the alpha code of your desired country in the second last line of the code. Here are a few examples.
The alpha code of UK is GB. So, if you want to set the default country to UK, the code will like the following.
/**
* Change the default country on the checkout page
*/
add_filter( 'default_checkout_billing_country', 'change_default_checkout_country' );
function change_default_checkout_country() {
return 'US'; // Put Country code here
}
You can find the alpha-2 code of any county here.
Summary
When most of the orders come from one particular country, it is good idea to set that country as the default country in checkout form. It helps customers to complete the process quickly.