Skip to content
Sign in
Campos Brasileiros para WooCommerce – CPF, CNPJ e CEP com validação icon

Campos Brasileiros para WooCommerce – CPF, CNPJ e CEP com validação

Campos brasileiros no checkout do WooCommerce: validar CPF e CNPJ pelo dígito verificador, preencher o endereço pelo CEP.

Not scanned yet WordPress plugin

Install in

No install steps yet

Follow the steps on the source page.

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:

  1. 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.
  2. 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.
  3. 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.

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:

  1. 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.
  2. Autofill. Type the CEP and the address fills itself in. Type the CNPJ and the company’s legal name and address come with it.
  3. 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.

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:

Written by Joobi from the project's own listing. See the source page

campos brasileiroscepcnpjcpfvalidar cpf
24 Nov 2026
Version 1.0.6 released. Not scanned yet.

1.0.6

  • Fix: on the classic checkout, letters typed just after changing the CEP could be lost, and the order stored “Cção” for “Consolação”. WooCommerce takes the focus away from every field when the order review update comes back with a notice; on some stores with plain permalinks a leftover “added to your cart” notice comes back on every update. The field being typed in now keeps the focus. This also happens without this plugin, in WooCommerce’s own fields, and they are protected too.
  • Fix: with the individual/company choice on, a CNPJ set to required was labelled “(optional)” on the classic checkout, although a company could not check out without it. It now carries the required mark. On WooCommerce 8.9 to 9.8 the block checkout labels it “CNPJ (obrigatório para PJ)” (CPF: “obrigatório para PF”).

1.0.4

  • Fix: on the classic checkout, a returning customer who shipped to the billing address got the street number and neighbourhood of their previous shipping address on the order’s shipping address, so the label pointed at the wrong house.
  • Fix: on WooCommerce 8.9 to 9.8, the block checkout with the individual/company choice showed no CPF, CNPJ or legal name field at all, and with a document set to required it refused every buyer. Those versions now show both documents and check the required one, for the chosen type, when the order is placed. WooCommerce 9.9 and later are unchanged.
  • Fix: on the classic checkout, a store that collects only company documents (CPF switched off, so no individual/company choice) did not enforce a required CNPJ and accepted a CNPJ with wrong check digits. Both are now refused, and the field is marked required.
  • New: WordPress’s “Export Personal Data” now includes the CPF, CNPJ, RG and the other fields this plugin stores, and “Erase Personal Data” removes them from the customer’s profile and, when WooCommerce is set to remove order data on request, from their orders.
  • Fix: searching WooCommerce > Orders for a CPF or CNPJ (digits only) finds the order on stores using High-Performance Order Storage, WooCommerce’s default. It only worked on the older posts storage.
  • Fix: on the classic checkout, a value posted for a field the store has switched off is no longer saved on the order.
  • Fix: a Shop Manager can save the settings screen. WordPress refused the save to anyone without the administrator’s capability.
  • Fix: an empty required Número or Bairro shows one error on the classic checkout, not two.
  • Fix: the Diagnostics panel now recognises Checkout Field Editor (it looked for the wrong file name) and this plugin’s own earlier build, sold as “Checkout Brasil”, which doubles every field when both are active.
  • Change: a field being looked up (CEP or CNPJ) stays dimmed until the answer arrives, rather than for a fixed 0.9 seconds. The spinner it was meant to show could never appear on an input.

1.0.3

  • Renamed to “Rebel Studios Brazilian Checkout Fields for WooCommerce” and moved to a unique, plugin-specific code prefix ahead of the WordPress.org listing. No change to features.
  • Documented the external services (ViaCEP, BrasilAPI) fully in the readme.

1.0.2

  • Fix: CEP autofill now sets the state. It filled street, neighbourhood and city but left the state WooCommerce preselects (the store’s own), so a Rio CEP on a São Paulo store kept “São Paulo”.
  • Fix: CNPJ autofill fills the registered address only as a whole, and only while the customer hasn’t started typing one, so it can no longer mix the company’s street into the customer’s CEP and state.

1.0.1

  • Fix: on the block checkout, a CNPJ typed digit by digit was scrambled by the input mask.
  • Fix: CEP and CNPJ autofill now works on the block checkout (it only worked on the classic checkout).
  • New on the block checkout: choose individual or company, with CPF, or CNPJ and legal name, to match.
  • New on the block checkout: street number and neighbourhood on the shipping address too, not only billing.
  • Fix: a CPF typed and then hidden by switching to company is no longer saved on the order (both checkouts).
  • Fix: documents were shown twice on the confirmation page and in emails for block checkout orders.

1.0.0

  • Initial release: CPF, CNPJ, legal name, RG, state registration, street number, neighbourhood and mobile phone.
  • Check-digit validation in the browser and on the server.
  • Address lookup by CEP (ViaCEP) and company lookup by CNPJ (BrasilAPI), server-side and cached.
  • Supports the classic checkout, the block checkout and HPOS.
  • Data on the order, the order screen, emails and the REST API.
12 Oct 2026Listed on Joobi from WordPress.org.

Follow this listing's changes (Atom feed)