Docs

Location Detection

2 min readUpdated October 19, 2026

When a visitor hasn’t chosen a country yet, Smart Phone Field finds their country from their IP address and starts the phone field on it. It can also fill an empty State / County field. Customers can always pick a different flag.

Set it up in WooCommerce > Smart Phone Field > Location.

A settings interface for visitor location detection. It features a toggle for “Detect visitor location” set to on, followed by dropdown menus for “Detection method,” “Backup API,” “freeipapi.com plan,” and “Visitor IP address,” each with descriptive text underneath.

Detection methods#

MethodHow it worksGood for
WooCommerce geolocation (default)Uses WooCommerce’s built-in lookupMost stores. No extra account.
CDN or hosting headersReads the country header your CDN or host adds (Cloudflare, Bunny, CloudFront, Vercel, CDN77, Sucuri, server GeoIP)Sites behind a CDN. Fast, with no outside call.
freeipapi.comAsks the freeipapi.com serviceFree plan: 60 lookups a minute. Paid plan with an API key or whitelisted server.
IP2Location.ioAsks the IP2Location.io serviceWithout a key: 1,000 lookups a day. A free key: 50,000 a month.

Without WooCommerce, the WooCommerce geolocation option uses your CDN or hosting headers instead.

Backup API#

With WooCommerce geolocation or CDN headers, you can choose freeipapi.com or IP2Location.io as a backup. It’s only asked when the first method finds no country, or no state when Pre-fill state is on.

Pre-fill state#

Also fills an empty billing or shipping State / County when the visitor’s country matches the selected one. IP2Location.io returns state codes only on a Plus plan. Otherwise the plugin matches the state by name.

Use for WooCommerce geolocation#

Lets WooCommerce use the same method for its own lookups: the checkout country and state pre-fill, and shipping and tax estimates. It only takes effect when WooCommerce > Settings > General > Default customer location is set to a Geolocate option.

Speed and caching#

  • The lookup runs separately from the page, so it works with page caching.
  • The lookup starts while the page is still loading.
  • If it takes longer than 2 seconds, the field starts on your store’s country (or your site language’s country) instead.
  • The result is remembered for one day, on your server and in the visitor’s browser, so repeat visits show the flag straight away. Only the country and state are kept.
  • API lookups are limited per visitor and site-wide, so nobody can use up a paid quota.

When no country is found#

The field starts on your store’s country. Without WooCommerce, it starts on your site language’s country (for example, English (United States) gives the US flag).

Behind a CDN or proxy? See CDN Proxy and Visitor IP.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only