Home / VAT API / Integrations / WooCommerce
WooCommerce EU VAT Validation API
Add EU VAT number validation to WooCommerce checkout. Verify EU business customers against VIES before applying zero-rate tax exemptions on cross-border B2B orders, using WooCommerce hooks and the TaxID REST API.
Quick start
CURL
curl -H "Authorization: Bearer YOUR_API_KEY" \ http://localhost:3000/api/v1/validate/DE/DE123456789
Code example
Full integration example including error handling for service_unavailable responses from VIES.
PHP (WooCommerce hooks)
<?php
// Add to functions.php or a custom plugin
// 1. Add VAT number field to WooCommerce checkout billing form
add_action('woocommerce_after_billing_form', 'taxid_add_vat_field');
function taxid_add_vat_field($checkout) {
woocommerce_form_field('eu_vat_number', [
'type' => 'text',
'label' => __('EU VAT Number (B2B customers)', 'woocommerce'),
'placeholder' => 'DE123456789',
'required' => false,
], $checkout->get_value('eu_vat_number'));
}
// 2. Validate via TaxID API before order is placed
add_action('woocommerce_checkout_process', 'taxid_validate_eu_vat');
function taxid_validate_eu_vat() {
$vat = sanitize_text_field($_POST['eu_vat_number'] ?? '');
if (!$vat) return;
$country = strtoupper(substr($vat, 0, 2));
$url = "http://localhost:3000/api/v1/validate/{$country}/{$vat}";
$response = wp_remote_get($url, [
'headers' => ['Authorization' => 'Bearer ' . TAXID_API_KEY],
'timeout' => 10,
]);
if (is_wp_error($response)) return; // allow through on network failure
$data = json_decode(wp_remote_retrieve_body($response), true);
if ($data['status'] === 'invalid') {
wc_add_notice(
__('Invalid EU VAT number. Please check and try again.', 'woocommerce'),
'error'
);
}
}
// 3. Save validated VAT number to order meta
add_action('woocommerce_checkout_create_order', 'taxid_save_vat_meta', 10, 2);
function taxid_save_vat_meta($order, $data) {
$vat = sanitize_text_field($_POST['eu_vat_number'] ?? '');
if ($vat) {
$order->update_meta_data('_eu_vat_number', $vat);
$order->update_meta_data('_eu_vat_validated_at', current_time('mysql'));
}
}cURL test
# Test your integration by calling the API directly:
curl "http://localhost:3000/api/v1/validate/DE/DE123456789" \
-H "Authorization: Bearer $TAXID_API_KEY"
# Response:
# {
# "valid": true,
# "status": "active",
# "company_name": "Example GmbH",
# "company_address": "Musterstraße 1, 10115 Berlin",
# "country_code": "DE",
# "vat_number": "DE123456789",
# "cached": false
# }API response
The TaxID API returns a consistent JSON response for every validation:
{
"valid": true,
"status": "active",
"country_code": "DE",
"vat_number": "DE123456789",
"company_name": "Example GmbH",
"company_address": "Musterstraße 1, 10115 Berlin",
"request_date": "2026-05-10T00:00:00.000Z",
"cached": false,
"request_id": "req_01j..."
}activeVAT number is valid and the business is registered
invalidVAT number format is wrong or not registered in VIES
service_unavailableVIES or the national authority is temporarily down — retry later, do not silently zero-rate
Implementation steps
- 1
Get a free TaxID API key
Sign up at taxid.dev/signup. Define the API key as a constant in wp-config.php (define('TAXID_API_KEY', 'your_key')) or load it from a secure environment variable. Never hardcode it in theme files or commit it to version control.
- 2
Add a VAT number field to WooCommerce checkout
Use the woocommerce_after_billing_form action hook to add a text field for the EU VAT number. Label it clearly as optional for consumers and required for B2B customers who want zero-rated invoices.
- 3
Validate via the TaxID API on order submission
Hook into woocommerce_checkout_process to call wp_remote_get() with the TaxID API endpoint and your Authorization header. Extract the country code from the first two characters of the VAT number. If status is 'invalid', call wc_add_notice() with an error message. If status is 'service_unavailable', allow through and log the event for manual follow-up.
- 4
Apply WooCommerce zero-rate tax class for valid EU businesses
When the API returns valid: true, apply WooCommerce's built-in 'Zero Rate' tax class to the order. You can do this by hooking into woocommerce_cart_tax_totals or by updating the customer's tax_exempt status programmatically via the WooCommerce REST API.
- 5
Store VAT number and validation result in order metadata
In the woocommerce_checkout_create_order hook, call $order->update_meta_data() to persist the VAT number and validation timestamp. This creates an auditable record for each order, which is required under EU invoice record-keeping obligations.
Frequently asked questions
Is there a WooCommerce plugin that does EU VAT validation?
Several plugins exist, but most use the raw VIES SOAP endpoint directly, which has no SLA and frequent downtime. The TaxID API wraps VIES with caching, rate limiting, and a stable REST interface — giving you more reliable validation with a simple HTTP call from your custom plugin or functions.php.
How do I zero-rate an order in WooCommerce for a validated EU business?
Apply WooCommerce's built-in 'Zero Rate' tax class to the customer or the cart when the VAT number validates as 'active'. You can update the customer's WooCommerce tax_exempt status, or override the tax totals in the woocommerce_cart_tax_totals filter for the current session.
What if VIES is down during WooCommerce checkout?
If the TaxID API returns service_unavailable, do not block the order or silently zero-rate it. The safest approach is to allow the order through with standard VAT rates, log the event, and send the customer a follow-up email asking them to provide their VAT number again. The TaxID API caches results for 24 hours, so most valid numbers will already be cached.
How do I validate UK VAT numbers in WooCommerce?
UK VAT numbers start with 'GB' and are validated via the HMRC API (not VIES). The TaxID API handles UK validation transparently — just pass the GB-prefixed number to the same endpoint (/api/v1/validate/GB/GB123456789) and it routes to HMRC automatically.
Country-specific API docs:
Start validating EU VAT numbers in WooCommerce
Free plan — 100 validations/month. No credit card required.