WordPress filter hook

woocommerce_countries

Defined by WooCommerce and fired by 9 plugins in total, running on 7M+ sites between them.

“Allows filtering of the list of countries in WC.”

How to use woocommerce_countries

It's a filter: your callback receives the value, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'woocommerce_countries', function( $value ) {
	// Change $value here.
	return $value;
}, 10, 1 );

Argument names come from Rooster One's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

9 plugins that fire woocommerce_countries

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. WooCommerce icon WooCommerce7+ million installs apply_filters( 'woocommerce_countries', include WC()->plugin_path() . '/i18n/countries.php' ) includes/class-wc-countries.php:184
  2. ALD icon ALD8,000+ installs apply_filters( 'woocommerce_countries', include WC()->plugin_path() . '/i18n/countries.php' ) includes/data.php:943
  3. Swift Performance Lite icon Swift Performance Lite6,000+ installs apply_filters( 'woocommerce_countries', include WP_PLUGIN_DIR . '/woocommerce/i18n/countries.php' ) includes/luv-framework/framework-config.php:69
  4. AliNext icon AliNext4,000+ installs apply_filters( 'woocommerce_countries', include WC()->plugin_path() . '/i18n/countries.php' ) includes/classes/model/Country.php:21
  5. Barcode Generator: Print Product and Order Labels with Barcodes (A4, Thermal/Roll, Letter) icon Barcode Generator: Print Product and Order Labels with Barcodes (A4, Thermal/Roll, Letter)900+ installs apply_filters( 'woocommerce_countries', include WC()->plugin_path() . '/i18n/countries.php' ) src/Classes/LabelDataMakers/Shortcodes/Woocommerce/OrderCustomField.php:52
  6. ESTO payment methods icon ESTO payment methods700+ installs apply_filters( 'woocommerce_countries', include WC()->plugin_path() . '/i18n/countries.php' ) esto-payment-methods.php:525
  7. Gigneo icon Gigneo10+ installs apply_filters( 'woocommerce_countries', gigneo_wc_i18n_data( 'countries.php' ) ) includes/helper-functions.php:258
  8. Rooster One icon Rooster One10+ installs apply_filters( 'woocommerce_countries', include $file ) includes/dmm/contact-form/class-aieo-contact-form.php:499
  9. Esell icon EsellFewer than 10 installs apply_filters( 'woocommerce_countries', include WC()->plugin_path() . '/i18n/countries.php' ) includes/dealbaoOrder/dealbaoOrder.class.php:124

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.