# Set the Default Checkout Country

> Pre-selects a billing and shipping country on checkout for new customers, which saves most of your buyers a step.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, checkout, countries
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-default-checkout-country/

## Code

```php
$wpide_default_country = 'US'; // Two-letter country code.

add_filter( 'default_checkout_billing_country', function ( $country ) use ( $wpide_default_country ) {
    return $country ? $country : $wpide_default_country;
} );

add_filter( 'default_checkout_shipping_country', function ( $country ) use ( $wpide_default_country ) {
    return $country ? $country : $wpide_default_country;
} );
```

## Notes

Use a two-letter country code. Returning customers keep the country saved in their account.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Set the Default Checkout Country" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
