Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kimwhite/b86b56640462151096b241f82e29aa9e to your computer and use it in GitHub Desktop.
Save kimwhite/b86b56640462151096b241f82e29aa9e to your computer and use it in GitHub Desktop.
Code to add to pmpro-customizations.php to adjust default country for Billing and for PMPro VAT
<?php // do not copy this line.
/**
* This recipe Default to country code for Germany AND add Default VAT country
* When using VAT TAX Add On https://www.paidmembershipspro.com/add-ons/vat-tax/
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
// Default Country
function my_set_pmpro_default_country( $default_country ) {
// Set country code to "GB" for United Kingdom.
$default_country = "DE";
return $default_country;
}
add_filter( 'pmpro_default_country', 'my_set_pmpro_default_country' );
// Default VAT Country
function init_set_default_vat_country_code() {
//default to German
if(!isset($_SESSION['eucountry'])) {
$_SESSION['eucountry'] = 'DE';
}
if(!isset($_REQUEST['eucountry'])) {
$_REQUEST['eucountry'] = $_SESSION['eucountry'];
}
}
add_action('init', 'init_set_default_vat_country_code');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment