How to enable users to search addresses by zip code?

How to enable users to search addresses by zip code?

Why does the plugin do not allow search by zip code out of the box?

From a User Experience point of view, because of the label of the form field, users will tend to start typing their desired street address and will be presented with address suggestions to select from. Entering the "Zipcode" in the "Street address" field doesn't feel natural to the users.

Moreover, users might confuse the first numbers presented in the address suggestions as being the "Zipcode" when, in fact, the Google Places API considers them the "house number", or vice versa.

For those reasons, only "Precise addresses" will be returned by the address search by default. This ensures the suggestions presented contain all available information for that address, including "zipcode" and the "house number".

There are some cases when it is desirable to allow users to search for zip code as in that country or culture, the "Zipcode" is usually the first address information the user is asked to fill in.

How to enable address search by zip code?

Since version 1.0.1, it is possible to change the types of search results returned by the Google Places API from the plugin settings.

To enable search by zip code:
  1. Visit the plugin settings page at  WP Admin > WooCommerce > Settings > Integrations > Google Address Autocomplete.
  2. Change the option selected for the field "Results types" to "Geocode, except businesses (geocode)".
  3. Save the changes.

Important: Please note that, due to limitations of the Google Places API, changing the type of search results may or may not work to enable search by zip code in your country or region.

What types of search results are supported?

The types of search results available from the plugin settings are the same as the support types of the Google Places API, except for the combination of `geocode` plus `establishment`, which in practice is the same as allowing "All types".

Visit the Google Places API documentation for more information about the supported types.

    • Related Articles

    • How to make house number required

      The case for mandatory house number in addresses When using Google Address Autocomplete to autofill the address fields, some customers forget to check or add a house number to their addresses. This problem causes issues with delivering the customer's ...
    • Getting started with Google Address Autocomplete

      How to get the Google Places API Key from Google Set up an account at Google Cloud Console First, you'll need to set up your Google Cloud Console Account, Enable billing and Create a new project. Follow the instructions on the Google Places API ...