Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save wbcomdev/95f494886ee1ad839d3f7578fcf990b2 to your computer and use it in GitHub Desktop.

Select an option

Save wbcomdev/95f494886ee1ad839d3f7578fcf990b2 to your computer and use it in GitHub Desktop.
/**
* Change the default country on the checkout for non-existing users only.
*/
function wb_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)
}
add_filter( 'default_checkout_billing_country', 'wb_change_default_checkout_country', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment