
Campos Brasileiros para WooCommerce – CPF, CNPJ e CEP com validação
v1.0.6Rebel Studios Software · 2026年10月12日 上架
Campos brasileiros no checkout do WooCommerce: validar CPF e CNPJ pelo dígito verificador, preencher o endereço pelo CEP. Dados no pedido e na API.
- 正在使用
- 10 以下
- 评分
- 暂无
- 累计下载
- 378
- 最近更新
- 2026年11月25日
截图
Este plugin adiciona ao checkout do WooCommerce os campos brasileiros que faltam: CPF, CNPJ, Razão Social, RG, Inscrição Estadual, número e bairro. E faz três coisas que normalmente faltam:
- Validação de verdade. CPF e CNPJ são conferidos pelo dígito verificador, no navegador e no servidor. Um documento inválido nunca chega ao pedido.
- Preenchimento automático. Digite o CEP e o endereço se preenche. Digite o CNPJ e a razão social e o endereço da empresa vêm junto.
- Os dados chegam onde você precisa. CPF, CNPJ e razão social aparecem na tela do pedido, nos e-mails e na REST API — prontos para a sua integração de nota fiscal (NF-e). Coletar um documento que você não consegue usar depois é justamente o problema que este plugin resolve.
CEP automático: o endereço se preenche sozinho
O cliente digita o CEP e quatro campos aparecem preenchidos — rua, bairro, cidade e estado. O número da casa ele ainda digita, porque consulta de CEP nenhuma sabe o número.
A consulta sai do seu servidor, nunca do navegador do cliente, e fica em cache por 30 dias: o mesmo CEP não é consultado duas vezes. Se o serviço de consulta estiver fora do ar, o campo continua editável e o cliente digita o endereço como sempre fez — a compra nunca é bloqueada por uma API de terceiros.
O detalhe que costuma dar errado nos outros: aqui o CEP manda na cidade e no estado. O seletor de estado nunca chega vazio, porque o WooCommerce já deixa o estado da própria loja escolhido, e sem forçar isso um CEP do Rio continua dizendo São Paulo. Já a rua e o bairro, se o cliente tiver digitado algo antes, ficam como ele escreveu.
Este plugin não calcula frete. Ele preenche o endereço e valida os documentos, e usa nomes próprios nos campos (billing_rsbcf_*) em vez de disputar os genéricos, então convive com o seu plugin de frete em lugar de brigar com ele.
Máscara de CPF, CNPJ e telefone enquanto se digita
A máscara de CPF (000.000.000-00), a de CNPJ (00.000.000/0000-00), a de telefone ((00) 00000-0000) e a de data (00/00/0000) são aplicadas conforme o cliente digita. Não carregamos biblioteca de máscara no seu checkout: o valor é reescrito no próprio campo, e um documento colado já formatado continua valendo.
O limite, dito de uma vez: a máscara é conveniência do navegador. Sem JavaScript não há máscara — e mesmo assim um CPF inválido não passa, porque o dígito verificador é conferido no servidor.
Para buscar CEP quem responde é o ViaCEP. A BrasilAPI é consultada apenas para o CNPJ.
Cada campo é opcional
Cada campo tem três estados: Desativado, Opcional ou Obrigatório. Nenhuma loja virtual é igual à outra: uma loja de produtos digitais não precisa pedir CPF; quem fatura para empresas precisa de CNPJ e razão social e nada mais. Você decide, sem mexer em código.
Funciona nos dois checkouts
Compatível com o checkout clássico e o checkout em blocos do WooCommerce, e com HPOS. Os dados são gravados do mesmo jeito nos dois, então a sua integração fiscal lê um formato só.
Privacidade
Nenhum dado do seu cliente passa por um servidor nosso. As consultas de CEP e CNPJ saem do seu site direto para os dois serviços públicos listados em Serviços externos, e a resposta fica em cache no seu site. Nós não recebemos nada, nem para estatística.
E para o lado de dentro: os documentos que este plugin grava entram na exportação e na exclusão de dados pessoais do WordPress — com um porém, que está no FAQ, porque a opção que apaga os dados do pedido vem desligada no WooCommerce.
In English
Brazilian Checkout Fields adds the fields a Brazilian store needs to the WooCommerce checkout — CPF, CNPJ, company legal name (Razão Social), RG, state registration (Inscrição Estadual), street number and neighbourhood (bairro) — and does three things that are usually missing:
- Real validation. CPF and CNPJ are checked against the official check digits, in the browser and on the server. An invalid document never reaches the order.
- Autofill. Type the CEP and the address fills itself in. Type the CNPJ and the company’s legal name and address come with it.
- The data goes where you need it. CPF, CNPJ and legal name appear on the order screen, in emails and in the REST API — ready for your invoicing (NF-e) integration. Collecting a document you cannot use later is the problem this plugin exists to solve.
The plugin’s interface is in Brazilian Portuguese. It is fully internationalized (i18n), so it can be translated into any language through translate.wordpress.org once published.
Automatic address fill from the CEP
The customer types the postcode (CEP) and four fields fill themselves in — street, neighbourhood, city and state. They still type the house number, because no postcode lookup knows it.
The lookup is made from your server, never from the customer’s browser, and is cached for 30 days, so the same CEP is never looked up twice. If the lookup service is down the field stays editable and the customer types the address as they always did — a purchase is never blocked by a third-party API.
The part that usually goes wrong elsewhere: here the CEP wins on city and state. The state select is never empty — WooCommerce preselects the store’s own state — so without forcing it, a CEP from Rio still says São Paulo. Street and neighbourhood, if the customer typed something first, are left as they wrote them.
This plugin does not calculate shipping. It fills the address and validates the documents, and it uses its own field names (billing_rsbcf_*) rather than the generic ones, so it lives alongside your shipping plugin instead of fighting it.
Input masks for CPF, CNPJ and phone
CPF (000.000.000-00), CNPJ (00.000.000/0000-00), phone ((00) 00000-0000) and date (00/00/0000) are masked as the customer types, by rewriting the field rather than loading a masking library, so a document pasted in already formatted still validates.
The limit, stated plainly: masking is a browser convenience. With JavaScript off there is no mask — and an invalid CPF still cannot get through, because the check digits are verified on the server.
Every field is optional
Each field has three states: Disabled, Optional or Required. A store that sells digital products does not need to ask for a CPF; one that invoices companies needs a CNPJ and legal name and nothing else. You decide, without touching code.
Works with both checkouts
Compatible with the WooCommerce classic checkout and the block checkout, and with HPOS (High-Performance Order Storage). Data is stored the same way by both checkouts, so an invoicing integration only has to read one format.
On the block checkout, customers choose between individual (Pessoa Física) and company (Pessoa Jurídica), and see only the documents for that choice.
Privacy
No customer data passes through a server of ours. CEP and CNPJ lookups go from your site straight to the two public services listed under External services, and the response is cached on your site. We receive nothing, not even analytics.
And on the inside: the documents this plugin stores are included in WordPress’s personal-data export and erasure — with one catch, in the FAQ, because the option that erases order data ships switched off in WooCommerce.
Inscrição Estadual and the accountant’s CSV (paid add-on)
This plugin stores the Inscrição Estadual; it does not check whether the number is well formed. Checkout Brasil Pro validates it against the published rule for each of the 27 states, at checkout, and exports a CSV of orders with CPF, CNPJ, Razão Social, IE and the full address — with an IE válida column, so an invalid registration is caught before anyone tries to issue the NF-e rather than after the sale.
It does not issue NF-e — that needs a digital certificate and a SEFAZ integration, and is a different product. $29/year or $87 once for a lifetime licence, 7-day refund. The free plugin above does not expire and is not limited by it.
External services
To fill an address from a postcode and a company from its registration number, this plugin sends the value the customer typed to two free, public Brazilian services. Every request is made from your server (never the customer’s browser), only when a customer enters a CEP or a CNPJ, and the response is cached on your site so the same value is not looked up twice. No data is ever sent to the makers of this plugin.
ViaCEP (https://viacep.com.br/)
Used to turn a Brazilian postcode into a street address. When a customer types an 8-digit CEP, that CEP — and nothing else — is sent to ViaCEP, which returns the street, neighbourhood, city and state. No personal data (name, email, document number) is sent. ViaCEP is a free public service that does not publish a separate terms-of-service or privacy-policy page; its usage information is on its website: https://viacep.com.br/.
BrasilAPI (https://brasilapi.com.br/)
Used to turn a company registration number into the company’s public details. When a customer types a 14-digit CNPJ (a public company registration number, not personal data), that CNPJ — and nothing else — is sent to BrasilAPI, which returns the company’s public registration data (legal name and registered address). BrasilAPI is a free, open-source community project. Its terms of use are published on its site: https://brasilapi.com.br/#termos-de-uso . It does not publish a separate privacy-policy page; the project and its source are documented at https://brasilapi.com.br/ .
The Diagnostics panel on the settings screen also sends one sample request to each service (at most once every 5 minutes) to show whether it is responding. It uses a fixed example CEP and CNPJ, never customer data.
Outros plugins da Rebel Studios
Plugins de WooCommerce que fazem uma coisa bem feita:
- Invoice Documents for WooCommerce: notas e recibos em PDF, romaneios e notas de entrega, gerados automaticamente.
- Restaurant Menu & Reservations: menu por QR code e reservas de mesa.
- Event Tickets & QR Check-in: eventos, RSVP e ingressos com QR para conferir na entrada.
- Membership & Content Restriction: restringe conteúdo a membros, com cadastro no front-end.


