Gatemi Address Autocomplete Developer Reference

The free edition applies no filters of its own. Everything under Filters is the full edition's.

Filters — Full edition

gmaa_enabled

Whether autocomplete runs on this request. Receives bool $enabled — true when the master switch is on, a key is saved and at least one address is on. Return false to load nothing.

// Only offer autocomplete to shoppers whose store country is the UK.
add_filter( 'gmaa_enabled', function ( $enabled ) {
	$country = WC()->customer ? WC()->customer->get_billing_country() : '';
	return $enabled && ( '' === $country || 'GB' === $country );
} );

gmaa_field_map

The map from Google's address components to WooCommerce field suffixes. Each entry is keyed by the suffix appended to billing_ / shipping_ and holds:

Key
components Google component types, in order
separator How several components are joined
first_only true to take only the first component found
short true to use Google's short text (codes) rather than long text

The default map:

array(
	'address_1' => array( 'components' => array( 'street_number', 'route' ), 'separator' => ' ' ),
	'address_2' => array( 'components' => array( 'subpremise' ), 'separator' => ' ' ),
	'city'      => array( 'components' => array( 'postal_town', 'locality' ), 'separator' => '', 'first_only' => true ),
	'postcode'  => array( 'components' => array( 'postal_code' ), 'separator' => '' ),
	'country'   => array( 'components' => array( 'country' ), 'separator' => '', 'short' => true ),
	'state'     => array( 'components' => array( 'administrative_area_level_1' ), 'separator' => '', 'short' => true ),
);

Example — write the route before the house number, as many continental European addresses are written:

add_filter( 'gmaa_field_map', function ( $map ) {
	$map['address_1']['components'] = array( 'route', 'street_number' );
	return $map;
} );

country is always written first by the script, whatever its position in the map.

gmaa_script_url

The URL of Google's Maps loader. The default is https://maps.googleapis.com/maps/api/js?key=<key>&libraries=places&v=weekly&loading=async. Use it to pin a Maps version, set region or language, or point at another endpoint.

add_filter( 'gmaa_script_url', function ( $url ) {
	return add_query_arg( array( 'v' => 'quarterly', 'region' => 'GB' ), $url );
} );

gmaa_settings

Filters the merged settings array (enabled, api_key, billing, shipping, countries) after it is read.

Licensing and boot

  • gmaa_license_api_url — the licence server's base URL.
  • gmaa_update_cache_ttl (default 12 hours), gmaa_update_retry_ttl (default 15 minutes), gmaa_sync_cache_ttl (default 12 hours) — seconds, never below 60.
  • gmaa_modules — the list of modules booted.

Actions — Full edition

  • gmaa_booted — after every module has booted; receives the container.

Scripts and data

Full edition Free edition
Google loader handle google-maps-places google-maps-places
Plugin script / style handle gmaa gmaaf
Localized object window.gmaaData window.gmaafData

The localized object holds key, sections (["billing","shipping"] or fewer), map, countries (up to five codes) and strings.placeholder.

The script listens for jQuery's updated_checkout and country_to_state_changed on document.body, when jQuery is present, and re-attaches to redrawn fields. On the Checkout block, whose fields carry ids but no name attribute and are rendered after load, a MutationObserver attaches when they appear, and a picked place is written through wp.data.dispatch( 'wc/store/cart' ).setShippingAddress() / setBillingAddress() in one call carrying the country and state. It listens for the element's gmp-select event and calls fetchFields( { fields: [ 'addressComponents' ] } ).

Assets load only on the checkout (is_checkout()) or My Account's edit-address endpoint, and only while autocomplete is enabled.

Options

Option Edition
gmaa_settings Both The five settings
gmaa_license Full Licence state

Transient gmaa_update_payload (full edition). Cron gmaa_license_check (full edition, twice daily, only once a licence key is entered). No tables, no post, order or user meta.

CSS classes

Class Element
.gmaa-search The Google search element inserted above the first address line
.gmaa-manual Added to the original address line, which stays visible

The plugin's stylesheet only sets the search box to full width with a small bottom margin; everything else is inherited from your theme. Google's dropdown is styled by Google.

Shopping Cart
Scroll to Top