WordPress filter hook
woocommerce_customer_default_location
Defined by WooCommerce and fired by 14 plugins in total, running on 7.9M+ sites between them.
“Filter the customer default location before geolocation.”
How to use woocommerce_customer_default_location
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_customer_default_location', function( $default_location ) {
// Change $default_location here.
return $default_location;
}, 10, 1 );Argument names come from WooPayments: Integrated WooCommerce Payments's source. Other plugins may pass different values: check the call in the plugin you're targeting below.
14 plugins that fire woocommerce_customer_default_location
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
WooCommerce7+ million installs
apply_filters( 'woocommerce_customer_default_location', $default_location_string ?? '' )includes/wc-core-functions.php:1241 -
WooPayments: Integrated WooCommerce Payments800,000+ installs
apply_filters( 'woocommerce_customer_default_location', $default_location )includes/multi-currency/Geolocation.php:64 -
Booster for WooCommerce30,000+ installs
apply_filters( 'woocommerce_customer_default_location', wcj_get_option( 'woocommerce_default_country' ) )includes/class-wcj-eu-vat-number.php:258 -
Currency Switcher for WooCommerce10,000+ installs
apply_filters( 'woocommerce_customer_default_location', get_option( 'woocommerce_default_country' ) )includes/functions/alg-switcher-functions.php:249 -
EU/UK VAT Validation Manager for WooCommerce7,000+ installs
apply_filters( 'woocommerce_customer_default_location', get_option( 'woocommerce_default_country' ) )includes/class-wpfactory-wc-eu-vat-ajax.php:117 -
Free Shipping Label and Progress Bar for WooCommerce5,000+ installs
apply_filters( 'woocommerce_customer_default_location', get_option( 'woocommerce_default_country', 'US:CA' ) )admin/fsl-threshold-status.php:179 -
Product Visibility by Country for WooCommerce400+ installs
apply_filters( 'woocommerce_customer_default_location', get_option( 'woocommerce_default_country' ) )includes/class-alg-wc-pvbc-core.php:534 -
MSRP (RRP) Pricing for WooCommerce200+ installs
apply_filters( 'woocommerce_customer_default_location', $this->options['default_wc_country'] )includes/class-alg-wc-msrp-core.php:863 -
Payment Gateways by Customer Location for WooCommerce100+ installs
apply_filters( 'woocommerce_customer_default_location', get_option( 'woocommerce_default_country' ) )includes/functions/alg-wc-pgbcl-functions-frontend.php:180 -
Product Price by Formula for WooCommerce100+ installs
apply_filters( 'woocommerce_customer_default_location', get_option( 'woocommerce_default_country' ) )includes/class-prowc-ppbf-shortcodes.php:564 -
Speedaf Express for woocommerce40+ installs
apply_filters( 'woocommerce_customer_default_location', $default_location )src/Speedaf/CreateOrder.php:323 -
DynamicBlocks10+ installs
apply_filters( 'woocommerce_customer_default_location', get_option( 'woocommerce_default_country' ) )admin/class/display-rules/checkout.php:338 -
Shop Currency Switcher for WooCommerce10+ installs
apply_filters( 'woocommerce_customer_default_location', get_option( 'woocommerce_default_country' ) )includes/functions/alg-switcher-functions.php:164 -
All In One For Woocommerce10+ installs
apply_filters( 'woocommerce_customer_default_location', aiow_option( 'woocommerce_default_country' ) )global/country.php:36
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.