Skip to content

Instantly share code, notes, and snippets.

@woogists
Last active July 9, 2018 19:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save woogists/796d3b26325c84a726b5bc1b1b3dd059 to your computer and use it in GitHub Desktop.
Save woogists/796d3b26325c84a726b5bc1b1b3dd059 to your computer and use it in GitHub Desktop.
[Frontend Snippets] Change the default country on the checkout (non-existing users only)
/**
* Change the default country on the checkout for non-existing users only
*/
add_filter( 'default_checkout_billing_country', 'change_default_checkout_country', 10, 1 );
function change_default_checkout_country( $country ) {
// If the user already exists, don't override country
if ( WC()->customer->get_is_paying_customer() ) {
return $country;
}
return 'DE'; // Override default to Germany (an example)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment