Filter
uncanny-automator-pro
uap_option_all_wc_countries
Filters the list of all WooCommerce countries available for United Affiliate Pro country-specific settings.
add_filter( 'uap_option_all_wc_countries', $callback, 10, 1 );
Description
Filters the list of all WooCommerce countries. Developers can use this hook to modify, add, or remove countries from the available list for Uncanny Automator Pro triggers and actions that require country selection, such as address-based automations. The hook fires after WooCommerce's countries are retrieved.
Usage
add_filter( 'uap_option_all_wc_countries', 'your_function_name', 10, 1 );
Parameters
-
$options(mixed) - This parameter contains an array of all available WooCommerce countries that can be used as options.
Return Value
The filtered value.
Examples
add_filter( 'uap_option_all_wc_countries', 'my_custom_wc_countries_filter', 10, 1 );
/**
* Filters the list of WooCommerce countries to remove specific countries.
*
* This function demonstrates how to modify the default list of WooCommerce countries
* provided by the Uncanny Automator Pro plugin. In this example, we'll remove
* 'US' (United States) and 'CA' (Canada) from the list.
*
* @param array $options An associative array of country codes to country names.
* @return array The modified array of country codes and names.
*/
function my_custom_wc_countries_filter( $options ) {
// Check if the input is an array, as expected.
if ( ! is_array( $options ) ) {
return $options; // Return as is if not an array.
}
// Define the country codes to remove.
$countries_to_remove = array( 'US', 'CA' );
// Loop through the countries to remove and unset them from the options array.
foreach ( $countries_to_remove as $country_code ) {
if ( isset( $options[ $country_code ] ) ) {
unset( $options[ $country_code ] );
}
}
// Return the filtered array of countries.
return $options;
}
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
uncanny-automator-pro/src/integrations/woocommerce/helpers/woocommerce-pro-helpers.php:447
public function get_countries() {
$cnt = new WC_Countries();
$options = $cnt->get_countries();
return apply_filters( 'uap_option_all_wc_countries', $options );
}