Created
March 14, 2025 16:59
-
-
Save rickalday/990c141589d94e921b594024ef6c7bc2 to your computer and use it in GitHub Desktop.
Limit Billing Address Block to specific country and state
This file contains 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
add_filter('give_countries', 'my_custom_give_countries'); | |
function my_custom_give_countries() { | |
$countries = array( | |
'CA' => esc_html__( 'Canada', 'give' ), | |
); | |
return $countries; | |
} | |
<?php | |
add_action('givewp_donation_form_schema', function($form) { | |
$countryField = $form->getNodeByName('country'); | |
if ($countryField){ | |
$countryField->defaultValue('CA'); | |
} | |
$province = $form->getNodeByName('state'); | |
$province->defaultValue('Alberta'); | |
}); | |
add_filter('give_canada_provinces', 'give_custom_provinces'); | |
function give_custom_provinces( $provinces ) { | |
$provinces = array( | |
'AB' => esc_html__( 'Alberta', 'give' ) | |
); | |
return $provinces; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment