Search by

arraypress / wp-google-address-validation

arraypress

A PHP library for integrating with the Google Address Validation API in WordPress, providing comprehensive address validation, standardization, and verification. Features WordPress transient caching and WP_Error support.

Package info

github.com/arraypress/wp-google-address-validation

Homepage

pkg:composer/arraypress/wp-google-address-validation

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

v1.0.0 2026-08-26 08:03 UTC

This package is auto-updated.

Last update: 2026-09-26 08:48:05 UTC


README

Check whether a delivery address is real and complete, before something is shipped to it.

What it does

A checkout will happily accept an address with the house number missing or the postcode from a neighbouring town. You find out when the parcel comes back.

Google's Address Validation API says how much of an address it could confirm, what it had to guess at, and what it corrected. This wraps that into questions you can act on — is this complete, was anything inferred, what did Google think it should say.

Features

  • Tell whether an address is complete enough to ship to
  • See which parts were confirmed, guessed at or replaced
  • Get Google's corrected version, to offer back to the customer
  • Read how precise the match is — a building, a street or just a town
  • Pull the standardised postal address, ready to store
  • Cache validations, since an address does not change between page loads

Installation

composer require arraypress/wp-google-address-validation

Quick start

Ask the customer to confirm, rather than silently correcting them:

use ArrayPress\Google\AddressValidation\Client;

$client = new Client( $api_key );
$result = $client->validate( [
	'regionCode'  => 'GB',
	'addressLines' => [ '10 Downing Street', 'London' ],
] );

if ( is_wp_error( $result ) ) {
	return; // Never block a sale on somebody else's uptime.
}

if ( ! $result->is_address_complete() ) {
	// Show $result->get_formatted_address() and ask them to confirm.
}

What it does not do

It does not tell you a person lives there, and a valid address is not a verified one. Treat a failed check as a prompt to confirm, never as grounds to refuse an order outright — the API's coverage varies by country and it is wrong more often in some than others.

Requirements

  • PHP 8.3 or later
  • WordPress 7.1 or later
  • A Google Maps Platform API key with Address Validation enabled

License

GPL-2.0-or-later