Created
April 7, 2022 09:28
-
-
Save wpfullstripe/a618a1605d9d37029d035d9f6e55aea6 to your computer and use it in GitHub Desktop.
The fullstripe_shipping_countries Wordpress filter
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
<?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