A lightweight, accessible WordPress plugin that adds Google Places address autocomplete to WooCommerce checkout pages. Built with WCAG AAA accessibility standards and full support for both classic and block-based checkouts.
- ✅ New Google Places API - Uses the latest REST-based Places API (v1)
- ✅ Universal Checkout Support - Works with both classic shortcode and block-based checkouts
- ✅ Session Token Optimization - Efficient billing with proper session token management
- ✅ Multi-Region Support - Configurable country restrictions
- ✅ HPOS Compatible - Fully compatible with WooCommerce High-Performance Order Storage
- ✅ Enhanced UK/IE Support - Proper handling of counties, postal towns, and flat numbers
- ✅ Single File - No external dependencies, everything inline
- WordPress: 5.8 or higher
- WooCommerce: 10.3 or higher
- PHP: 7.4 or higher
- Google Places API Key: With Places API (New) enabled
- Go to the Google Cloud Console
- Create a new project (or select an existing one)
- Navigate to APIs & Services → Library
- Search for and enable "Places API (New)" (NOT the old Places API)
- Go to APIs & Services → Credentials
- Click "Create Credentials" → "API Key"
- Copy your API key
- (Recommended) Click on your new API key to restrict it:
- Application restrictions: Select "HTTP referrers"
- Add your domain(s):
yourdomain.com/* - API restrictions: Select "Restrict key" and choose "Places API (New)"
- Save changes
- Download
woo-google-address-autocomplete.php - Go to WordPress Admin → Plugins → Add New → Upload Plugin
- Choose the file and click Install Now
- Click Activate
- Download
woo-google-address-autocomplete.php - Upload to
/wp-content/plugins/woo-google-address-autocomplete/ - Go to WordPress Admin → Plugins
- Find "WooCommerce Google Address Autocomplete (Accessible)" and click Activate
- Go to WooCommerce → Settings → Advanced → Features
- Check the box for "Address Autocomplete"
- Click "Save changes"
This enables WooCommerce's built-in address autocomplete system that the plugin hooks into.
-
Go to WooCommerce → Settings → Integration
-
Click on "Google Places" (it will appear after activation)
-
Configure the following settings:
- Enable/Disable: Check to enable Google address autocomplete
- Google API Key: Paste your API key from Step 1
- Country Restrictions (Optional): Enter comma-separated 2-letter country codes
- Example:
GB,IE(UK and Ireland only) - Example:
US,CA(USA and Canada only) - Leave empty to allow all countries
- Example:
-
Click "Save changes"
-
Registration Phase
- Plugin extends
WC_Integrationto add settings page - Extends
WC_Address_Providerto register with WooCommerce's autocomplete system - Declares compatibility with HPOS and address autocomplete features
- Plugin extends
-
Frontend Loading
- Checks if checkout page is loaded (classic or block)
- Verifies address autocomplete is enabled in WooCommerce
- Confirms API key is configured
- Enqueues JavaScript with dependency on
wc-address-autocomplete
-
Autocomplete Flow
- User types in address field (minimum 3 characters)
- Plugin calls Google Places API Autocomplete endpoint with session token
- Results are formatted and displayed in WooCommerce's autocomplete dropdown
- User selects an address
- Plugin calls Google Places API Details endpoint to get full address
- Address components are parsed and mapped to WooCommerce fields:
street_number+route→ Address Line 1subpremise→ Address Line 2 (flat/unit number)localityorpostal_town→ Cityadministrative_area_level_1oradministrative_area_level_2→ State/Countypostal_code→ Postcodecountry→ Country
- Session token is regenerated for the next search
The plugin implements Google's recommended session token pattern to minimize API costs:
- One token per search session
- Token is sent with all autocomplete requests
- Token is regenerated after place selection
- This groups all autocomplete requests + the final details request into a single billable session
The plugin includes enhanced logic for UK and Ireland addresses:
- Prioritizes
administrative_area_level_2(county) for GB/IE - Falls back to
postal_townwhenlocalityis not available - Properly handles
subpremisefor flat/apartment numbers - Uses short codes for country and state (e.g., "GB" not "United Kingdom")
You can limit autocomplete suggestions to specific countries:
- Go to WooCommerce → Settings → Integration → Google Places
- In the "Country Restrictions" field, enter 2-letter ISO country codes separated by commas
- Examples:
- UK only:
GB - UK and Ireland:
GB,IE - North America:
US,CA,MX - European Union:
AT,BE,BG,HR,CY,CZ,DK,EE,FI,FR,DE,GR,HU,IE,IT,LV,LT,LU,MT,NL,PL,PT,RO,SK,SI,ES,SE,GB
- UK only:
Note: If you leave this field empty, the plugin will suggest addresses from all countries.
-
Check WooCommerce Feature is Enabled
- Go to WooCommerce → Settings → Advanced → Features
- Ensure "Address Autocomplete" is checked
-
Verify API Key
- Go to WooCommerce → Settings → Integration → Google Places
- Confirm your API key is correctly entered
- Test the key in Google's API Key Validator
-
Check API is Enabled
- In Google Cloud Console, verify "Places API (New)" is enabled
- NOT the old "Places API" - it must be the new one
-
Check Browser Console
- Open browser developer tools (F12)
- Look for JavaScript errors in the Console tab
- Common errors:
- "WooCommerce address autocomplete not loaded" → WooCommerce feature not enabled
- "Google API key not configured" → API key missing or not saved
- "Autocomplete API error: 403" → API key restrictions too strict or API not enabled
- Check if you have country restrictions enabled
- Go to WooCommerce → Settings → Integration → Google Places
- Either remove restrictions or add your country code to the list
This is usually because Google doesn't have complete data for that address. The plugin fills in whatever Google provides. You can:
- Try a more specific search
- Select a different suggestion
- Manually complete the missing fields
The plugin uses two API endpoints:
- Autocomplete (per session) - ~$2.83 per 1,000 sessions
- Place Details (per request) - $0.017 per request
One session = Multiple autocomplete requests + one details request
With session tokens properly implemented (as in this plugin), a typical checkout completion costs:
- 1 session + 1 details request = ~$0.003 per checkout
Google provides $200 free credit per month, which covers approximately:
- ~66,000 address autocompletes per month
- ~2,200 checkouts per day
For most stores, this plugin will cost nothing under the free tier.
Current Google Places API Pricing
- Plugin only loads on checkout pages
- API key is not exposed to the public (stored in WP database)
- No user data is stored by the plugin
- All API calls are made directly from the user's browser to Google
- Plugin declares GDPR/privacy considerations are handled by Google's terms
- Complete rewrite using new Google Places API (v1)
- Added support for block-based checkout
- Implemented proper WooCommerce integration system
- Added session token optimization
- Enhanced UK/IE address parsing
- Added HPOS compatibility
- Improved accessibility (WCAG AAA)
- Added dark mode support
- Single-file architecture
- Used old Google Maps JavaScript API
- Supported classic checkout only
Found a bug or have a feature request? Please open an issue on the GitHub repository.
GPL v2 or later
Simon Harper (SRH Design)
- Website: https://srhdesign.co.uk/
- Built on WooCommerce's native address autocomplete system
- Uses Google Places API (New)
- Inspired by Nadir Seghir's implementation approach
Need help? Check the troubleshooting section above or open an issue on GitHub.