Forked from kimwhite/pmpro-defult-country-code.php
Last active
March 27, 2024 13:57
-
-
Save dwanjuki/981d74267c5626fdacc0e2d0b346fe81 to your computer and use it in GitHub Desktop.
Set a default billing country and VAT country
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 sets a default billing country and VAT country | |
* | |
* 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 "SE" for Sweden. | |
$default_country = "SE"; | |
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 Sweden | |
if( ! isset( $_SESSION['eucountry'] ) ) { | |
$_SESSION['eucountry'] = 'SE'; | |
} | |
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