Datos fiscales: NIF, CIF y NIE for WooCommerce

By dozish16

0+ active installationsVersion 1.0.0

Adds a validated Spanish tax ID field (NIF, CIF or NIE, with control letter and digit check) to the WooCommerce checkout.

Description

Datos fiscales: NIF, CIF y NIE adds the data you need to issue full invoices to Spanish customers: the NIF, NIE or CIF, properly validated, not just “9 characters long”.

Features

  • Adds a NIF/CIF/NIE field to the block checkout (the default in new stores) and to the classic checkout.
  • Validates the control letter or digit:
    • NIF (DNI): 8 digits and a letter (modulo 23). Special NIFs K, L and M too.
    • NIE: X, Y or Z, 7 digits and a letter.
    • CIF: entity letter, 7 digits and control (digit or letter depending on the entity type).
  • Accepts lowercase, spaces, dots and hyphens (12.345.678-z) and stores the clean value (12345678Z).
  • Three modes: optional, required or conditional (required when the customer fills in “Company” or when the order is above an amount; 400 € by default, the general simplified-invoice limit; retail stores may use up to 3,000 €; editable).
  • Spanish rules only apply to customers billed in Spain: customers billed in another country are never asked for the field and can type their own tax ID in any format.
  • Optional legal name (razón social) field.
  • Option to accept EU VAT numbers from other EU countries (basic format check only; numbers with the ES prefix are fully validated).
  • Saves the value in the order and in the customer profile, and pre-fills it on later purchases.
  • Shows it in the admin order screen (editable), WooCommerce e-mails, the thank-you page and My Account.
  • Compatible with HPOS (high-performance order storage).
  • In every language of Spain: Spanish, Catalan, Valencian, Galician, Basque, Aranese and Aragonese. Each user sees the admin in the language of their profile (Users → Profile → Language); customers see the language of the site.
  • Free, with no locked features.

Legal notice

This tool helps you apply taxes in WooCommerce, but it does not replace the advice of a tax adviser. Review the settings with your adviser.

Privacy

  • The plugin does not send data to third parties: no external services, no telemetry, no usage tracking.
  • The tax ID is stored only in your database, in the order and in the customer profile.
  • It is included in the WordPress personal data export, removed when you erase a customer’s personal data, and deleted from orders that WooCommerce anonymizes (only if you enable that in WooCommerce). The plugin also suggests a paragraph for your privacy policy (Settings → Privacy).
  • Validation runs on your server with the official control letter/digit algorithm. It does not query the Spanish Tax Agency or VIES, so it does not check that the number exists or who it belongs to.

More free tools for Spanish stores

  • Recargo de Equivalencia for WooCommerce.
  • Canarias, Ceuta y Melilla (IGIC and IPSI) for WooCommerce.
  • Exportación para la gestoría for WooCommerce (sales invoice book and tax summary).

Installation

  1. Install and activate WooCommerce (8.0 or later).
  2. Upload the datos-fiscales-nif-cif-nie folder to /wp-content/plugins/ or install it from “Plugins → Add New”.
  3. Activate it.
  4. Go to WooCommerce → Settings → Tax IDs (NIF) and choose the field mode.

FAQ

Where can I get help?

Use the support forum of the plugin on WordPress.org or write to soporte.plugins.online@gmail.com.

Does it work with the block checkout?

Yes. It uses WooCommerce’s official Additional Checkout Fields API (WooCommerce 8.6 or later). With WooCommerce 8.0 to 8.5 the field only appears in the classic checkout.

Does it check that the NIF exists?

No. It checks the format and the control letter or digit, which catches almost all typing mistakes. It does not query any external database.

When should I make it required?

It depends on your business. Spanish rules (RD 1619/2012, art. 4) allow a simplified invoice without the customer tax ID up to 400 € VAT included, and up to 3,000 € for retail sales to final consumers. Business customers can always ask for a full invoice with their tax ID. The “conditional” mode asks for it from companies and above the amount you choose. Check with your adviser.

Where is the tax ID stored?

In the order, with the meta key _billing_dfnifwc_tax_id, and in the customer profile, with billing_dfnifwc_tax_id. The legal name uses _billing_dfnifwc_company_name and billing_dfnifwc_company_name. PDF invoice plugins can display these custom fields.

What happens if I uninstall the plugin?

Its settings are deleted. Tax IDs stored in orders (fiscal records of your store) and in customer profiles are never deleted.

I am a developer: how do I read the tax ID from another plugin?

With filters that return the default value when this plugin is not active:

$nif = apply_filters( 'dfnifwc_order_tax_id', '', $order );
$legal_name = apply_filters( 'dfnifwc_order_company_name', '', $order );
$customer_nif = apply_filters( 'dfnifwc_customer_tax_id', '', $user_id );

Screenshots

Changelog

1.0.0

  • First release: validated NIF/CIF/NIE field in the classic and block checkout, optional, required and conditional modes, legal name field, EU VAT numbers, and display in orders, e-mails and My Account.
  • Customers billed outside Spain are never required to fill in the field and can type their own tax ID.
  • A tax ID removed by the customer or by the store is cleared everywhere.
  • Integration with the WordPress personal data export and erasure tools.