Hi, how’s it going?
Every day, we have to open a support ticket with VTEX because the platform validates incorrect ZIP codes that don’t match the customer’s address or simply don’t exist.
I’ve already asked about doing an external validation, but support doesn’t recommend making that change in the checkout. If VTEX can’t fix this, how could we solve it then?
A second problem is that since these ZIP codes are invalid, the street, city, and state don’t get filled in automatically. The customer has to type the rest of the address manually. When there are typos, the order doesn’t integrate into our system, and in the end we have to cancel it.
What could we do to resolve these situations?
Hi @celinne, how are you?
Unfortunately, there’s nothing native in VTEX’s checkout that handles or corrects this type of scenario.
VTEX works with the assumption that the postal code (CEP) has all 8 digits. If the CEP doesn’t exist, there is currently no validation in place for that.
If I were to suggest something — though it’s not recommended — it would be to have a customization that checks whether the CEP is valid using a Correios API, a public government external API, or Google’s API.
However, this type of customization could drastically affect site performance, since every time the user types, an external request would need to be made.
Another option is to try using a Google Maps API to look up addresses, but that could also put the checkout at risk.
Some other options:
The public external API that can serve this same purpose is: https://www.gov.br/conecta/catalogo/apis/cep-codigo-de-enderecamento-postal/swagger-json/swagger_view#tag/Consultar-CEP
Via CEP API: https://viacep.com.br/
OpenCEP: https://opencep.com/
APICep: API de Consulta | Api CEP
Google Maps API: Visão geral da API Geocoding | Geocoding API | Google for Developers
VTEX already advises that they do not recommend customizations in the checkout, as it can break the purchase flow and they will not provide support for it.
But these alternatives do exist.
Hope this helps.
Best,
Estevão.