[Frontend Snippets] Change the default country on the checkout (non-existing users only)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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