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:

functions.php
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.

  1. WooCommerce icon WooCommerce7+ million installs apply_filters( 'woocommerce_customer_default_location', $default_location_string ?? '' ) includes/wc-core-functions.php:1241
  2. WooPayments: Integrated WooCommerce Payments icon WooPayments: Integrated WooCommerce Payments800,000+ installs apply_filters( 'woocommerce_customer_default_location', $default_location ) includes/multi-currency/Geolocation.php:64
  3. Booster for WooCommerce icon 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
  4. Currency Switcher for WooCommerce icon Currency Switcher for WooCommerce10,000+ installs apply_filters( 'woocommerce_customer_default_location', get_option( 'woocommerce_default_country' ) ) includes/functions/alg-switcher-functions.php:249
  5. EU/UK VAT Validation Manager for WooCommerce icon 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
  6. Free Shipping Label and Progress Bar for WooCommerce icon 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
  7. Product Visibility by Country for WooCommerce icon 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
  8. MSRP (RRP) Pricing for WooCommerce icon 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
  9. Payment Gateways by Customer Location for WooCommerce icon 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
  10. Product Price by Formula for WooCommerce icon 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
  11. Speedaf Express for woocommerce icon Speedaf Express for woocommerce40+ installs apply_filters( 'woocommerce_customer_default_location', $default_location ) src/Speedaf/CreateOrder.php:323
  12. DynamicBlocks icon DynamicBlocks10+ installs apply_filters( 'woocommerce_customer_default_location', get_option( 'woocommerce_default_country' ) ) admin/class/display-rules/checkout.php:338
  13. Shop Currency Switcher for WooCommerce icon Shop Currency Switcher for WooCommerce10+ installs apply_filters( 'woocommerce_customer_default_location', get_option( 'woocommerce_default_country' ) ) includes/functions/alg-switcher-functions.php:164
  14. All In One For Woocommerce icon 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.