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.
Opens WPIDE on
Code
$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 add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.