Rebel Studios Brazilian Checkout Fields for WooCommerce

Description

Rebel Studios 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 street, neighbourhood, city and state fill 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.

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 and reliability

CEP and CNPJ lookups are made from your server, not from the customer’s browser, and are cached. If a lookup service is down, the customer simply types the address — a purchase is never blocked by a third-party API.

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.

Screenshots

Installation

  1. Install and activate the plugin.
  2. Go to WooCommerce Checkout Brasil.
  3. For each field, choose Disabled, Optional or Required.

FAQ

The fields do not appear on my checkout.

It is almost always the checkout type. If your store uses the block checkout and your previous plugin only supported the classic checkout, no fields appear — which is exactly why this plugin exists.

Go to WooCommerce Checkout Brasil and look at the Diagnostics panel at the bottom of the page. It tells you which checkout your store uses, whether the fields are active, and whether another plugin is competing for the same fields. Copy that report before opening a support request.

Can I turn off the CPF?

Yes. Every field has three states — Disabled, Optional, Required — under WooCommerce Checkout Brasil. Nothing is forced, including the CPF.

The fields appear twice.

You have two checkout-field plugins active at the same time. The Diagnostics panel detects the common ones (Brazilian Market on WooCommerce, Checkout Field Editor, Flexible Checkout Fields). Deactivate one of them.

I am migrating from “Brazilian Market on WooCommerce”. Is my old data lost?

Old orders stay intact — this plugin deletes nothing. It stores data in its own meta keys (_billing_rsbcf_cpf), different from the old plugin’s (_billing_cpf), precisely to avoid conflicts. New orders use the new keys; old orders remain readable by the old plugin while it is installed.

CEP lookup stopped working. Can my customers still buy?

Yes. A failed lookup is ignored and the customer types the address normally. A purchase is never blocked by a third-party API. The Diagnostics panel shows whether ViaCEP and BrasilAPI are responding right now.

Do CPF/CNPJ show up on the invoice?

They are stored on the order (_billing_rsbcf_cpf, _billing_rsbcf_cnpj, _billing_rsbcf_company_legal_name) and shown on the order screen, in emails and in the REST API — which is where NF-e integrations read them. If your integration expects different field names, the rsbcf_order_values filter lets you remap them.

Does it work with HPOS?

Yes, compatibility is declared. Data is saved through the WooCommerce order API, so it works the same with HPOS on or off.

Does it work with PagSeguro / Mercado Pago / PagBank?

The fields use their own names (billing_rsbcf_*) instead of the generic names several plugins fight over, which is the most common cause of gateway conflicts. If you still hit a conflict, send the Diagnostics report and we can answer on the first reply.

Is the CPF really validated?

Yes, with the official check digits, in the browser and again on the server. An invalid document never reaches the order. Repeated sequences (111.111.111-11) are rejected.

Do you receive my customers’ data?

No. Lookups go from your server straight to ViaCEP and BrasilAPI, and responses are cached on your site. There is no server of ours in between.

Reviews

There are no reviews for this plugin.

Contributors & Developers

“Rebel Studios Brazilian Checkout Fields for WooCommerce” is open source software. The following people have contributed to this plugin.

Contributors

Changelog

1.0.5

  • 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.