Skip to content

NIP at checkout

Business customers need a NIP field at checkout to receive a VAT invoice. Polski for WooCommerce adds a NIP field with checksum validation and GUS REGON verification. Company data fills in automatically.

The NIP module verifies the number at three levels:

  1. Format validation - checking that the number consists of 10 digits
  2. Checksum validation - NIP check digit verification algorithm
  3. GUS REGON verification - checking in the Central Statistical Office database with automatic company data retrieval

Enable the module under Polski > Modules and expand its settings.

The module has three settings, all under Polski > Modules > NIP.

Setting Default value Description
NIP required on checkout No Makes the NIP field mandatory. Left off, the field is optional.
GUS API environment Testing Testing uses the GUS sandbox key, Production uses your own.
GUS API Key (production) empty Requested from the stat.gov.pl website.

Checksum validation always runs and is not a setting. Company data is retrieved from GUS whenever a valid NIP is entered and a working key is configured.

Where the field appears, and where the company name comes from

Section titled “Where the field appears, and where the company name comes from”

Turning the module on adds one field, NIP, and nothing else. There is no setting that shows or hides it conditionally: it is present on the checkout for every customer, optional unless you make it required.

The company name is WooCommerce’s own billing field, not ours. Show or hide it under WooCommerce > Settings > Accounts and Privacy, or in the Checkout block’s settings on block checkout, where “Company” can be set to hidden, optional or required. Polski reads whatever WooCommerce stores there and does not override it.

The NIP validation algorithm is based on a weight system. The check digit (last, tenth digit) is calculated based on the nine preceding digits.

Weights for consecutive NIP digits: 6, 5, 7, 2, 3, 4, 5, 6, 7

NIP: 1234567890
Sum = 1*6 + 2*5 + 3*7 + 4*2 + 5*3 + 6*4 + 7*5 + 8*6 + 9*7 = 214
Remainder = 214 mod 11
If remainder == last NIP digit -> NIP is valid

The plugin validates both client-side (JavaScript) and server-side (PHP). Server-side validation is always active.

The plugin accepts NIP in various formats:

  • 1234567890 - digits only
  • 123-456-78-90 - with hyphens
  • 123 456 78 90 - with spaces
  • PL1234567890 - with country prefix

All formats are normalized to 10 digits before validation.

The GUS REGON API requires an access key. The plugin supports two environments:

Environment URL Key Use
Test https://wyszukiwarkaregontest.stat.gov.pl/wsBIR/UslugaBIRzewnwordbir.svc abcde12345abcde12345 (public test key) Development and testing
Production https://wyszukiwarkaregon.stat.gov.pl/wsBIR/UslugaBIRzewnetrzny.svc Your own key from GUS Live store
  1. Go to: https://api.stat.gov.pl/Home/BirIndex
  2. Register and log in
  3. Submit a request for REGON API access
  4. The key will be sent to the provided email address (wait time: 1-3 business days)
  1. Go to Polski > Modules > NIP
  2. Enable GUS REGON verification
  3. Select environment: Test or Production
  4. Paste the API key (for the production environment)
  5. Save settings

In test mode, the plugin uses the public GUS test key. The test database contains fictitious data. Use it only during development and testing.

After verifying NIP in GUS REGON, the plugin automatically completes form fields:

WooCommerce field GUS data
Company Company name
Address 1 Street and number
City City
Postal code Postal code
State/Province Province

The customer sees the completed data and can correct them before placing the order.

  • Fields are completed only if they are empty or contain previously retrieved GUS data
  • If the customer manually changed the data, the plugin does not overwrite changes
  • The customer is informed with a message about the data retrieval

The NIP number is saved as order metadata:

  • key: _billing_nip
  • visible in the admin panel order view
  • available in email templates
  • exportable in reports

NIP is automatically displayed:

  • in order details (admin panel)
  • in the order confirmation email
  • on the “My Account > Orders” page
$order = wc_get_order($order_id);
$nip = $order->get_meta('_billing_nip');
function validate_nip(string $nip): bool {
$nip = preg_replace('/[^0-9]/', '', $nip);
if (strlen($nip) !== 10) {
return false;
}
$weights = [6, 5, 7, 2, 3, 4, 5, 6, 7];
$sum = 0;
for ($i = 0; $i < 9; $i++) {
$sum += (int) $nip[$i] * $weights[$i];
}
return ($sum % 11) === (int) $nip[9];
}
add_filter('polski/checkout/validate_nip', function (bool $is_valid, string $nip): bool {
// Additional validation logic
// e.g. checking against a blocked NIP list
$blocked_nips = ['0000000000'];
if (in_array($nip, $blocked_nips, true)) {
return false;
}
return $is_valid;
}, 10, 2);
  1. Check that the API key is correct and active
  2. Verify that the server can establish an HTTPS connection to api.stat.gov.pl
  3. The GUS API can be unavailable - the plugin handles timeouts and displays an appropriate message
  4. Make sure the PHP SOAP extension is installed on the server
  1. Check that the NIP module is enabled
  2. Verify the conditional display setting
  3. Clear cache (caching plugins may cache the checkout form)
  1. Check the browser console for AJAX errors
  2. Verify that the plugin REST API endpoint is accessible
  3. Make sure the NIP is correct and the company exists in the GUS database
This page is for informational purposes only and does not constitute legal advice. Consult a lawyer before implementation. Polski for WooCommerce is open source software (GPLv2) provided without warranty.