Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wpfullstripe/a618a1605d9d37029d035d9f6e55aea6 to your computer and use it in GitHub Desktop.
Save wpfullstripe/a618a1605d9d37029d035d9f6e55aea6 to your computer and use it in GitHub Desktop.
The fullstripe_shipping_countries Wordpress filter
<?php
/**
* A 'fullstripe_shipping_countries' filter hook example for WP Full Stripe.
*
* @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 shipping countries.
* formType => Type of the form that requires the list of shipping 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 getShippingCountries( $countryCodes, $params) {
$result = $countryCodes;
// Set Italy, United States, and Hungary as the shipping countries if the name of the form is 'paymentInlineDefault'
// For every other form, display all countries
if ( $params['formName'] === 'paymentInlineDefault' ) {
$result = [ 'IT', 'US', 'HU' ];
}
return $result;
}
add_filter('fullstripe_shipping_countries', 'getShippingCountries', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment