Real Simple Autocomplete for WooCommerce

Descrição

Real Simple Autocomplete fills WooCommerce checkout street, city, state, postcode, and country fields using Google Places and OpenStreetMap for greater definition and coverage.

Refresh-safe checkout updates

A defining feature of RSAC is its checkout request guard. WooCommerce normally recalculates totals whenever address fields change. Autocomplete fills several dependent fields in quick succession, which can otherwise start overlapping recalculations using incomplete address data.

While the shopper types and selects an autocomplete result, RSAC temporarily suppresses same-origin WooCommerce checkout requests while continuing to allow Google Places and OSM traffic. After the complete address has been applied, RSAC releases the guard and allows one coherent checkout recalculation.

Focusing an address field and leaving it without changing the street value releases the request guard without requesting a checkout refresh. Manual edits and autocomplete selections still use the normal completion/update flow.

This helps prevent:

  • Recalculations using partially populated addresses.
  • Competing country, state, postcode, shipping, and tax updates.
  • Checkout totals being calculated from stale field values.
  • Classic checkout loading overlays becoming stuck after an intentionally blocked refresh.
  • Excessive Store API batch requests in Checkout Blocks while autocomplete is active.

The request guard supports both classic checkout and Checkout Blocks and remains replaceable through window.rsacCheckoutRequestGuard for advanced integrations.

Additional features

  • Legacy Google Places Autocomplete or opt-in Places API (New).
  • Accessible, keyboard-navigable suggestions panel for Places API (New).
  • International address-component handling and manually entered house-number preservation.
  • Matches Google region codes and names directly to WooCommerce states, with an optional cached OSM fallback for unresolved regions.
  • Missing house-number notification and administrator-scoped diagnostics.

External services

This plugin does not send analytics or tracking data to the plugin author. It uses the following external services to provide address autocomplete and optional state or province matching. Depending on applicable law, site owners may need to describe these services in their privacy notice or obtain appropriate consent.

Google Maps Platform and Places API

Google Maps Platform is required for the plugin’s address autocomplete functionality.

The site owner should restrict the Google API key to the site’s HTTP referrers and to the Maps JavaScript API plus the enabled Places API.

When an enabled checkout page loads, the shopper’s browser requests the Google Maps JavaScript API. This request includes the site owner’s Google API key, the configured language and region, and standard connection information such as the shopper’s IP address and browser request data. As the shopper types in an enabled address field, the entered address text is sent to Google Places to obtain suggestions. Selecting a suggestion sends its Place identifier to Google to retrieve address components such as street, city, state, postcode, and country.

Google provides this service under its own policies:

  • Google Maps Platform Terms of Service: https://cloud.google.com/maps-platform/terms/
  • Google Privacy Policy: https://policies.google.com/privacy

OpenStreetMap Nominatim

OpenStreetMap Nominatim is optional. When enabled, it is used only if Google’s state or province code and name cannot be matched directly to a WooCommerce state option.

In that fallback case, the latitude and longitude of the selected Google Place are sent to the public Nominatim reverse-geocoding service to obtain an ISO state or province code. With direct requests, the shopper’s browser also sends standard connection information such as its IP address and browser request data. With the optional WordPress proxy cache enabled, the request is sent by the website server and also includes the site locale and a User-Agent containing the site URL. The plugin then caches only the country-and-region state-code mapping for 24 hours; it does not cache the shopper’s complete address or Google Places responses.

OpenStreetMap Foundation provides this service under its own policies:

  • Nominatim Usage Policy: https://operations.osmfoundation.org/policies/nominatim/
  • OpenStreetMap Foundation Terms of Use: https://osmfoundation.org/wiki/Terms_of_Use
  • OpenStreetMap Foundation Privacy Policy: https://osmfoundation.org/wiki/Privacy_Policy

Perguntas frequentes

Why does RSAC pause WooCommerce checkout requests?

Autocomplete changes multiple address fields as one operation. Allowing WooCommerce to refresh after every intermediate field can produce overlapping requests, incomplete shipping or tax calculations, and stuck loading states. RSAC pauses those requests until the selected address is fully applied, then releases the guard for the final checkout update. Google Places and OSM requests are not blocked.

Why is a postcode missing for some addresses?

Google Places returns a postcode only when the selected Place result contains a postal_code address component. This varies by address and region and is generally not controlled by the plugin API settings. When Google does not return a postcode, RSAC clears any postcode left from the previously selected address.

How can I style the Places API (New) autocomplete panel?

These controls apply only when Places API (New) is enabled; they do not affect the legacy Google Autocomplete widget. Expand the “Places API (New) Panel Styling” section to customize:

  • Normal suggestions: panel background and text colors.
  • Highlighted suggestions: separate background and text colors for hover, focus, and keyboard selection.
  • Panel border: border color and corner radius.
  • Size and spacing: suggestion font size, vertical/horizontal padding, panel maximum height, and z-index.

Dimensions are in pixels. Font size 0 inherits the checkout font size. Existing colors are preserved, and the highlight text color initially uses the normal text color. Choose readable text/background combinations for both normal and highlighted suggestions. The section is collapsed by default; its fields are still saved normally.

To supply all panel appearance yourself, enable “Disable built-in panel styling”. RSAC then skips its panel appearance stylesheet and saved styling overrides. Essential positioning, visibility, and scrolling CSS remains, along with autocomplete behavior and attribution markup. The setting affects only the Places API (New) panel, not the legacy widget or checkout notifications. Keep the attribution visible and provide a visible hover/keyboard-selection style in your custom CSS. Uncheck the option to restore your saved styling settings.

For additional styling, target these selectors in your theme or custom CSS:

.rsac-autocomplete-panel - suggestions container.
.rsac-autocomplete-option - individual suggestion.
.rsac-autocomplete-option.is-active - keyboard-selected or highlighted suggestion.
.rsac-google-maps-attribution - Google Maps attribution.

The panel also supports these CSS custom properties:

--rsac-panel-background
--rsac-panel-text
--rsac-panel-active
--rsac-panel-active-text
--rsac-panel-border
--rsac-panel-radius
--rsac-panel-font-size
--rsac-panel-padding-y
--rsac-panel-padding-x
--rsac-panel-max-height
--rsac-panel-z-index

How can I collect a debug report?

Select a Debug User and enable Browser debug logging in the plugin settings. Reproduce the checkout problem while logged in as that administrator, open the browser developer console, and run:

rsacGetDebugReport()

Logging requires the selected user to be logged in with administrator settings permissions. An empty Debug User selection never enables logging for guests. Both console output and reports redact recognized credentials, and the report omits the page query string and fragment.

Copy the returned JSON when requesting support. The report can contain entered address data, but API keys and nonces are excluded or redacted. Run rsacClearDebugReport() before reproducing if you want to discard earlier entries.

How do I know whether another component loads Google Maps?

Visit checkout while logged in as an administrator with settings permissions. RSAC shows an administrator-only notice when it detects an external Google Maps JavaScript loader, or a warning if multiple loader script tags are present. A working external loader is informational, not an error. WordPress script handles or script element IDs are shown when available; loaders without an ID are marked “unregistered-maps-loader”. Ordinary shoppers do not receive these notices.

Collision prevention, multiple loaders, script loading errors, missing Places functionality, failed Places imports, and timeouts also produce console warnings, including for guests, without enabling debug logging. RSAC waits up to 20 seconds for Maps and up to 20 seconds for a Places import. A late successful import can still initialize autocomplete; RSAC never loads a second Maps copy as a fallback.

The latest check is shown at the top of RSAC settings for up to 24 hours. The separate “Google Maps Loader Log” tab keeps the latest 50 issue events, with time, page path, and other script handles/IDs. Identical events for the same path and handles are recorded at most once per 10 minutes. Server-side prevention is logged for all visitors; browser-detected issues are saved only when an administrator visits checkout. The log is stored in a non-autoloaded WordPress option and can be cleared from that tab with an administrator-only, nonce-protected form. Neither the log nor console diagnostics include URL query strings, API keys, customer address fields, or raw Google error messages. Revisit checkout after changing loader settings to refresh diagnostics.

RSAC detects queued WordPress scripts, including dependencies and scripts already printed, and rechecks immediately before printing its own Maps loader. If another registered loader appeared late, RSAC skips only its own loader. Other components’ scripts are never removed. It also watches for Google Maps script tags inserted later in the page. Already-executed, hardcoded, aggregated, or hidden loaders cannot always be prevented or attributed to a particular plugin. If an external component is responsible for Maps, enable “Don’t load Google Maps Javascript API scripts” and ensure that component provides the Places library needed by the selected API mode.

How are repeated OSM requests reduced?

Identical simultaneous OSM lookups share one request. Successful results are reused in memory for five minutes on the current page, with a maximum of 20 entries. Failed requests are not cached. This page cache is cleared when the page is reloaded and does not store Google Places responses. The optional WordPress cache additionally shares verified country and region mappings across visitors for 24 hours.

Can I retain the previous OSM region matcher?

The previous permissive matcher remains available as rsac_osm_region_matches_legacy. By default, RSAC verifies every provided region label using Unicode-aware matching before sharing a cache entry. If verification is uncertain, the result is still returned for the current address but is not shared in the region cache.

Developers can select the previous behavior with add_filter( 'rsac_osm_region_matcher', function () { return 'rsac_osm_region_matches_legacy'; } );. This restores permissive cache validation and should be used only when the site’s region data requires it.

Avaliações

Não há avaliações para este plugin.

Colaboradores e desenvolvedores

“Real Simple Autocomplete for WooCommerce” é um programa de código aberto. As seguintes pessoas contribuíram para este plugin.

Colaboradores