Adds a postcode lookup tool into WooCommerce's billing and shipping address areas on the Checkout. The postcode lookup tool uses https://getaddre …
|Author:||Gareth 'GazChap' Griffiths (profile at wordpress.org)|
|WordPress version required:||4.8.0|
|WordPress version tested:||5.7.2|
|Added to WordPress repository:||24-02-2019|
|Total downloads:||2 045|
Click to start download
This plugin enables your customers to complete their billing/shipping address by entering their postcode and selecting their address from the options given.
It utilises getAddress.io (https://getaddress.io) to do the lookup using their Royal Mail Postcode Address File.
An API key is required for the integration to work, and the integration only appears when the customer has selected United Kingdom (or, more specifically, the ISO-3166-2 code “GB”) for their country.
It can optionally be turned off for the shipping or billing addresses, and it can be configured to send an email notification to a nominated address if the getAddress.io API key hits its usage limit.
getAddress.io offers several test postcodes that can be entered to test that it is working without impacting on your usage limits. These are:
XX2 00X - Returns a 'successful' response 200. Your request was successful. XX4 04X - Returns 'not found' error 404. No addresses could be found for this postcode. XX4 00X - Returns 'bad request' error 400. Your postcode is not valid. XX4 01X - Returns 'forbidden' error 401. Your api-key is not valid. XX4 29X - Returns 'too many requests' error 429. You have made more requests than your allowed limit. XX5 00X - Returns 'server error' error 500. Server error, you should never see this.
See the getAddress.io documentation (https://getaddress.io/Documentation) for more details.
Once installed and activated, you need to go to the WooCommerce -> Settings -> General page in the WordPress dashboard. You can enter your API key and set your other options here.
For developers, I’ve included a few filters that you can use to customise certain aspects of the plugin. These are:
All of these filters take one argument,
gazchaps-woocommerce-getaddress-io_find-address-button-text - the text shown on the Find Address buttons (default: Find Address) gazchaps-woocommerce-getaddress-io_find-address-searching-text - the text shown when the Find Address button is selected (default: Searching...) gazchaps-woocommerce-getaddress-io_enter-address-manually-text - the text shown for the "Enter an address manually" link (default: Enter an address manually)
Note: Although these two texts are translateable, filters will override any translations.
All of these filters take one argument,
$message, the error message that will be displayed to the user.
gazchaps-woocommerce-getaddress-io_api_error_400 - shown when the postcode supplied is invalid/empty gazchaps-woocommerce-getaddress-io_api_error_401 - shown when the API key provided in the settings is invalid gazchaps-woocommerce-getaddress-io_api_error_404 - shown when no addresses were found for the supplied postcode gazchaps-woocommerce-getaddress-io_api_error_429 - shown when the API key has hit its usage limit gazchaps-woocommerce-getaddress-io_api_error_500 - shown when there is a server error at getAddress.io
Note: By default, the error messages are “customer friendly”, i.e. they don’t go into much detail about the cause of the error!
gazchaps-woocommerce-getaddress-io_billing_selector_row_class - changes the CSS class on the form-row that the billing address selector is placed into gazchaps-woocommerce-getaddress-io_shipping_selector_row_class - changes the CSS class on the form-row that the shipping address selector is placed into gazchaps-woocommerce-getaddress-io_clear_additional_fields - defaults to true, set to '__return_false' to stop the "additional fields" area of the checkout having a clear style applied to it
Over Usage Email Notification
gazchaps-woocommerce-getaddress-io_overusage_email_recipient - change the recipient passed to wp_mail() gazchaps-woocommerce-getaddress-io_overusage_email_subject - change the subject line passed to wp_mail() for the over-usage email gazchaps-woocommerce-getaddress-io_overusage_email_message - change the message body passed to wp_mail() for the over-usage email<h3>License</h3>Licensed under the [GNU General Public License v2.0](http://www.gnu.org/licenses/gpl-2.0.html)
The Find Address button on the default Storefront theme, before the lookup has been completed
The address selection drop-down menu on display
The administrator settings in the WooCommerce administration dashboard
The address lookup feature within the WooCommerce add/edit order screen
- Fixed an issue with the Enter/Return key (or equivalent on mobile) submitting the entire checkout form instead of triggering the postcode lookup. Thanks to donlee101 for the report.
- Fixed a bug with the new hide address fields option not functioning correctly when GB is the only country available to select. Thanks again to prodograw.
- Removed reliance on certain CSS classes in the checkout, as some themes apparently don’t use them. Thanks to prodograw for the report.
- Fixed a bug that would stop the “tidy postcode” routine running when looking up a postcode currently in the cache
- Removed some duplicate JS that had crept in
- Somehow the push I did to the WordPress plugin repo missed some files – hopefully this will fix it…
- Added postcode lookup to the WooCommerce admin when creating and editing orders
- Added option (disabled by default) to hide the address input fields until an address has been selected
- Added option to show an “Enter address manually” button for use in conjunction with the above “hide address fields” option
- Added new filter for changing the “Enter address manually” text
- Added link to getaddress.io in plugin settings
- Updated donation link to Ko-Fi instead of PayPal
- Fix layout issue seemingly introduced by the WooCommerce 4.4 update, that pushed the “Find Address” button on to the next row.
- The address results selector now works properly in the Account pages on the front-end. Thanks to Ben Wheeler for some additional assistance here.
- Added an additional “Searching…” state when the button is clicked for better user experience
- Added settings in WC admin panel to change the text shown on the Find Address button, and the text shown in the new “Searching…” state
- Added filters for the above texts for developer control
- Uses the postcode returned by getAddress.io to “tidy up” the postcode field after the lookup is completed. Thanks to bootle for the suggestion.
- Updated JS to trigger WooCommerce’s order update Ajax request when an address is selected. Thanks to rfvdan for the report.
- Added a caching mechanism to prevent repeated lookups for the same postcode in the same browser session, thus saving API usage
- Initial release.