Skip to content

Instantly share code, notes, and snippets.

@wpfullstripe
Last active April 7, 2022 09:23
Show Gist options
  • Save wpfullstripe/226436a07574b40d8fdd794e98580c65 to your computer and use it in GitHub Desktop.
Save wpfullstripe/226436a07574b40d8fdd794e98580c65 to your computer and use it in GitHub Desktop.
The fullstripe_billing_countries Wordpress filter
<?php
/**
* A 'fullstripe_billing_countries' filter hook example for WP Full Stripe.
* It sets Spain as the only country offered in billing country dropdown on all forms.
*
* @param string $countryCodes Array of 2-letter ISO country codes returned by previous filters of the chain.
* @param array $params with the following keys:
* formName => Name of the form that requires the list of billing countries.
* formType => Type of the form that requires the list of billing countries. Possible values:
* inline_payment
* checkout_payment
* inline_subscription
* checkout_subscription
* inline_donation
* checkout_donation
* inline_save_card
* checkout_save_card
*
* @return string Filtered array of 2-letter ISO country codes
*/
function getBillingCountries( $countryCodes, $params) {
$result = $countryCodes;
// Set Spain as the only billing country for every form
$result = [ 'ES' ];
return $result;
}
add_filter('fullstripe_billing_countries', 'getBillingCountries', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment