Forked from pbrocks/pmpro-defult-country-code.php
Last active
March 27, 2024 13:52
-
-
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
This file contains hidden or 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
<?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