[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