Set the Default Country on WooCommerce Checkout
Out of the box, WooCommerce’s checkout country dropdown either shows whatever country WooCommerce geolocates from the customer’s IP, or defaults to the store’s base country if geolocation is off. Neither is right for every store. If 95% of your customers are in one country and the geolocation guess is wrong (it often is on cached sites, CDNs, or mobile networks), customers have to scroll a country list of 200+ entries to fix it. That friction costs conversions.
WooCommerce exposes two filters for this: default_checkout_billing_country for the billing form and default_checkout_shipping_country for shipping. Return the ISO country code you want, and that’s the value the dropdown loads with. Customers can still change it; you’re just setting the default.
/**
* Set the default country on the WooCommerce checkout page.
*
* Use the two-letter ISO 3166-1 alpha-2 country code
* (US, CA, GB, AU, DE, FR, IN, BR, etc).
*/
add_filter('default_checkout_billing_country', 'carticy_default_checkout_country');
add_filter('default_checkout_shipping_country', 'carticy_default_checkout_country');
function carticy_default_checkout_country()
{
return 'US';
}
Hooking both filters keeps the billing and shipping defaults consistent. If you only want to set one, remove the matching add_filter() line. Common codes: US United States, CA Canada, GB United Kingdom, AU Australia, DE Germany, FR France, IN India, BR Brazil. The full list is the standard ISO 3166-1 alpha-2 set.
Set Country AND State Together
If most of your customers are in one state or province, you can also pre-fill the state dropdown. The state filter expects the state code (two-letter US state, three-letter Canadian province, etc.) and only triggers when the billing country matches your default.
/**
* Pre-fill default country AND state on the WooCommerce checkout.
*/
add_filter('default_checkout_billing_country', function () {
return 'US';
});
add_filter('default_checkout_billing_state', function () {
return 'CA'; // California
});
add_filter('default_checkout_shipping_country', function () {
return 'US';
});
add_filter('default_checkout_shipping_state', function () {
return 'CA';
});
Geolocation Conflicts
If WooCommerce geolocation is enabled (WooCommerce > Settings > General > Default customer location), it may override your filter. Geolocation runs before the default filters and supplies its own country guess. Two options: turn geolocation off, or change the setting to “Shop base address” which makes WooCommerce respect the filter values you’ve set. The “Geolocate (with page caching support)” option works around CDN caching but is slower and still occasionally guesses wrong.
For stores with a clearly dominant customer market, hardcoding the country via this snippet is often more reliable than IP-based detection. The 5% of customers from elsewhere have to change the dropdown once; the 95% never have to think about it.
Verification
- Add the snippet to your child theme’s
functions.phpor a custom plugin - Open the checkout page in an incognito window (logged out, fresh session)
- Confirm the country dropdown is pre-selected to the country code you set
- Confirm the state dropdown is pre-selected (if you used the state filter)
- Change the country manually and confirm the form still lets you submit normally
Need Help?
Learn how to add custom code to WordPress or reach out for custom development help.
About the Author
More Code Snippets
-
Reorder the Columns on the WooCommerce Orders List
Put your WooCommerce orders list columns in whatever order works…
-
Bulk Delete Expired Unused WooCommerce Coupons (Batched, Safe)
One-time bulk cleanup utility for stores with thousands of expired,…
-
Stop WooCommerce Webhooks from Firing on Staging Sites
Stop WooCommerce webhooks from firing on staging sites and accidentally…