Skip to content

Instantly share code, notes, and snippets.

@rickalday
Created March 14, 2025 16:59
Show Gist options
  • Save rickalday/990c141589d94e921b594024ef6c7bc2 to your computer and use it in GitHub Desktop.
Save rickalday/990c141589d94e921b594024ef6c7bc2 to your computer and use it in GitHub Desktop.
Limit Billing Address Block to specific country and state
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