Update: Version 2.2 released on 10th February 2022, on the WordPress plugin repository.
This, my third WordPress plugin (and also my third WooCommerce plugin, apparently I really like doing stuff with WooCommerce!) adds a postcode lookup tool to the checkout in WooCommerce 3.x that lets your UK-based customers quickly fill in their billing/shipping addresses based on their postcode.
It utilises the great getAddress.io API for the postcode lookup, and as such requires an API key for their service. I’d always recommend the £10 per month pricing plan, simply because it offers the best value, but they have a number of others available.
- Adds postcode lookup for both billing and shipping addresses
- Administrators can turn off the lookup for either address, if needed
- (v1.1) Uses an internal cache for each customer to prevent repeated calls for the same postcode eating up API usage limits
- Correctly uses the WooCommerce “locale” system to show and hide the lookup button when appropriate
- Has full internationalisation (i18n) and localisation (l10n) support – so if you want to translate the plugin into your own language, please get in touch!
The plugin adds a Find Address button next to the postcode field, and moves the Postcode field so that it is the first field filled in after selecting United Kingdom as the country.
When the Find Address button is clicked, the user is presented with a menu of available addresses:
In the WordPress back-end, administrators have the following settings available:
As with all WordPress plugins, you just need to drop the plugin folder into your wp-content/plugins folder and then activate the “GazChap’s WooCommerce getAddress.io Postcode Lookup” plugin.
I’m using WordPress 5.1 and WooCommerce 3.5.5 – please let me know in the comments if it doesn’t work on other versions. I believe it requires at least WooCommerce 3.0.0.
Download the plugin from the WordPress Plugin Repository
This plugin is open-source – view the source code on the GitHub repository.
Plugin the best I’ve seen and by far the cheapest api calls.
I would like to request a change.
Is there anyway you could hide the address fields until an address is selected from the dropdown and also can the postcode field be converted to uppercase input.
Great work btw!
Hi Carl, thanks for the great feedback! I like the suggestions, will see what I can do 🙂 If you haven’t already, it would be super-appreciated if you could leave a rating/review on the WordPress plugin repository 🙂 Thanks again!
Seems to work on the checkout, and shows on the account address pages but doesn’t actually fill anything in on the account address pages. Is this a bug?
Hope this can be either fixed or removed from account address pages and just left in checkout page.
Twenty Twenty theme btw!
Thanks for the report – yes, this is a bug. It hadn’t occurred to me that it would add the lookup to the account pages too, but as that would be a useful feature I’ll try and fix that.
Hi. Thanks for the plugin.
I got it working on the My Account pages as well as Checkout.
It’s a very simple change to one selector.
In gazchaps-getaddress-io.min.js, replace the string
“.woocommerce-address-fields, .woocommerce-billing-fields, .woocommerce-shipping-fields”
This way, the plugin should work on any address form no matter where it is on the site, as long as it calls the hooks that you’re using.
Thanks Ben – I’d already done something similar, but somehow I didn’t spot the shorter class (I was using the __wrapper one!)
Have just pushed an update to the plugin live on the repository incorporating this and a few other changes, thanks for your help 🙂
Really nice plugin, thanks GC: I was playing with I also tried with an incorrect postcodes (first two characters are a post town, but everything else is invalid) and the town was populated and an error message was displayed
Secondly I also tried with invalid postcode (first two characters don’t exist in the PAF), and received an error message as expected: is there a way to make that message appear closer to the entry field rather than at the top of the screen, and can the message be more verbose, for example “that postcode doesn’t exist, please check and try again”?
I hesitate to ask because the plugin works fine and it’s free, but I thought I’d mention it anyway.
Sorry for the delay responding.
The error messages can be changed with the filters – see the readme.txt in the plugin folder for details.
It would perhaps make more sense for the error to be shown next to the field though rather than as a standard browser alert at the top – I’ll add this to my list of changes.
Thanks for your kind words and feedback!