WordPress filter hook
woocommerce_sort_countries
Defined by WooCommerce and fired by 6 plugins in total, running on 7M+ sites between them.
“Filters whether the list of countries is sorted by name.”
How to use woocommerce_sort_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:
add_filter( 'woocommerce_sort_countries', function( $value ) {
// Change $value here.
return $value;
}, 10, 1 );Argument names come from WooCommerce's source. Other plugins may pass different values: check the call in the plugin you're targeting below.
6 plugins that fire woocommerce_sort_countries
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
WooCommerce7+ million installs
apply_filters( 'woocommerce_sort_countries', true )includes/class-wc-countries.php:192 -
ALD8,000+ installs
apply_filters( 'woocommerce_sort_countries', true )includes/data.php:944 -
AliNext4,000+ installs
apply_filters( 'woocommerce_sort_countries', true )includes/classes/model/Country.php:22 -
ESTO payment methods700+ installs
apply_filters( 'woocommerce_sort_countries', true )esto-payment-methods.php:526 -
Payment Gateways by Customer Location for WooCommerce100+ installs
apply_filters( 'woocommerce_sort_countries', true )includes/functions/alg-wc-pgbcl-functions-admin.php:44 -
EsellFewer than 10 installs
apply_filters( 'woocommerce_sort_countries', true )includes/dealbaoOrder/dealbaoOrder.class.php:125
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.