WooCommerce Checkout in Brazil: What Ships Broken, and Why
Originally published on rebelstudiossoftware.com . A buyer in Rio reaches your checkout. The store was set up in São Paulo, so the state dropdown already reads São Paulo . She types her CEP, the street and neighbourhood fill in from it, she pays, and her order ships to the wrong state at the wrong freight price. Nothing threw an error. She did everything right. A postal code that fills the…
When a buyer in Rio attempts to checkout from a WooCommerce store set up in São Paulo, the address often ends up being shipped to the wrong state with incorrect freight pricing. This occurs because the store's default WooCommerce checkout is missing crucial features necessary for properly handling Brazilian addresses and forms. The most common issue is when an autofill feature using a CEP (postal code) overwrites the pre-selected state, despite the fact that the state field is not initially empty.
The correct approach is to fully overwrite fields that the buyer cannot accurately input, such as state and city, while only suggesting values for fields they might have already entered, like the street. By following this logic, the bug causing orders to be shipped to the wrong state can be prevented.
In Brazil, WooCommerce must ask whether the buyer is a person (pessoa física) or a company (pessoa jurídica), as this determines which CPF or CNPJ must be collected. The store should validate the document fields based on the customer's type, ensuring the mask and check-digit rules are applied correctly. Additionally, WooCommerce should support PIX, Brazil's instant bank transfer method, by providing a buyer-friendly approach.
This can be achieved by handing over the Pix key and exact amount upon order confirmation, while reconciling the payment manually. Implementing these fixes not only ensures that orders are shipped correctly but also enhances the overall purchasing experience for Brazilian customers.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.