For Developers
This section is intended for developers who want to integrate the module with custom solutions or invoicing plugins.
Order Meta Data
Section titled “Order Meta Data”Business Details
Section titled “Business Details”| Meta key | Description | Example |
|---|---|---|
_billing_ic | Company ID (identification number) | 12345678 |
_billing_dic | Tax ID (tax identification number) | CZ12345678 |
_billing_dic_dph | VAT ID (Slovakia only) | SK1234567890 |
VAT Exemption
Section titled “VAT Exemption”| Meta key | Description | Values |
|---|---|---|
is_vat_exempt | WooCommerce standard - VAT exemption | yes / no |
_wpify_vat_exempt_reason | Exemption reason | domestic, export, reverse_charge, legacy, standard |
Example of Getting Data from Order
Section titled “Example of Getting Data from Order”$order = wc_get_order( $order_id );
// Business details$ic = $order->get_meta( '_billing_ic' );$dic = $order->get_meta( '_billing_dic' );$dic_dph = $order->get_meta( '_billing_dic_dph' );
// VAT exemption - use WooCommerce method$is_vat_exempt = wc_string_to_bool( $order->get_meta( 'is_vat_exempt' ) );$vat_exempt_reason = $order->get_meta( '_wpify_vat_exempt_reason' );Customer Meta Data
Section titled “Customer Meta Data”| Meta key | Description |
|---|---|
billing_ic | Customer Company ID |
billing_dic | Customer Tax ID |
billing_dic_dph | Customer VAT ID (SK) |
Getting Data from Customer
Section titled “Getting Data from Customer”// Recommended way - using WC_Customer object$customer = WC()->customer;
// VAT exemption - primary source is customer$is_vat_exempt = $customer->get_is_vat_exempt();
// Business details$ic = $customer->get_meta( 'billing_ic' );$dic = $customer->get_meta( 'billing_dic' );
// Alternatively from user meta$user_id = get_current_user_id();$ic = get_user_meta( $user_id, 'billing_ic', true );$dic = get_user_meta( $user_id, 'billing_dic', true );Available Filters
Section titled “Available Filters”wpify_woo_icdic_eu_country_codes
Section titled “wpify_woo_icdic_eu_country_codes”Modifies the list of EU countries for Reverse Charge calculation.
apply_filters( 'wpify_woo_icdic_eu_country_codes', $eu_countries );| Parameter | Type | Description |
|---|---|---|
$eu_countries | array | Array of EU country codes (e.g., ['CZ', 'SK', 'DE', ...]) |
Return value: array - Modified array of country codes
Example:
/** * Modify EU countries list * * @param array $countries Array of EU country codes * * @return array Modified country array */function my_modify_eu_countries( array $countries ): array { // Add country (e.g., after EU accession) $countries[] = 'XX';
// Remove country $countries = array_diff( $countries, array( 'GB' ) );
return $countries;}add_filter( 'wpify_woo_icdic_eu_country_codes', 'my_modify_eu_countries' );wpify_woo_icdic_vat_id_valid_for_exempt
Section titled “wpify_woo_icdic_vat_id_valid_for_exempt”Custom Tax ID validation for VAT exemption. Allows VIES bypass or custom verification.
apply_filters( 'wpify_woo_icdic_vat_id_valid_for_exempt', $is_valid, $vat_id );| Parameter | Type | Description |
|---|---|---|
$is_valid | bool | Validation result (from VIES or basic check) |
$vat_id | string | Tax ID to validate (including country prefix, e.g., CZ12345678) |
Return value: bool - Whether Tax ID is valid for exemption
Example:
/** * Custom Tax ID whitelist * * @param bool $is_valid Validation result * @param string $vat_id Tax ID to validate * * @return bool Modified result */function my_vat_id_whitelist( bool $is_valid, string $vat_id ): bool { // Custom Tax ID whitelist - always valid $whitelist = array( 'CZ12345678', 'SK1234567890' );
if ( in_array( $vat_id, $whitelist, true ) ) { return true; }
return $is_valid;}add_filter( 'wpify_woo_icdic_vat_id_valid_for_exempt', 'my_vat_id_whitelist', 10, 2 );wpify_woo_icdic_destination_country
Section titled “wpify_woo_icdic_destination_country”Overrides destination country used for VAT calculation.
apply_filters( 'wpify_woo_icdic_destination_country', $destination_country, $billing_country, $shipping_country, $shop_country );| Parameter | Type | Description |
|---|---|---|
$destination_country | string | Calculated destination country (per WooCommerce settings) |
$billing_country | string | Customer billing country code |
$shipping_country | string | Customer shipping country code |
$shop_country | string | Shop country code |
Return value: string - Country code for VAT calculation
Example:
/** * Always use billing country for B2B * * @param string $destination Calculated destination country * @param string $billing Billing country * @param string $shipping Shipping country * @param string $shop Shop country * * @return string Modified destination country */function my_destination_country( string $destination, string $billing, string $shipping, string $shop ): string { // For B2B always use billing country if ( WC()->customer && WC()->customer->get_meta( 'billing_ic' ) ) { return $billing; }
return $destination;}add_filter( 'wpify_woo_icdic_destination_country', 'my_destination_country', 10, 4 );wpify_woo_icdic_vat_exempt_result
Section titled “wpify_woo_icdic_vat_exempt_result”Overrides VAT exemption decision.
apply_filters( 'wpify_woo_icdic_vat_exempt_result', $result, $billing_country, $shipping_country, $vat_id, $destination_country );| Parameter | Type | Description |
|---|---|---|
$result | array | Result: ['exempt' => bool, 'reason' => string] |
$billing_country | string | Billing country code |
$shipping_country | string | Shipping country code |
$vat_id | string | Customer Tax ID |
$destination_country | string | Destination country for calculation |
Return value: array - ['exempt' => bool, 'reason' => string]
Possible reason values:
domestic- Domestic sale (destination country = shop country)export- Export to third countries outside EUreverse_charge- EU Reverse Charge (B2B within EU)legacy- Exempted via deprecated settingstandard- Standard sale without exemption
Example:
/** * Exempt from VAT for specific countries outside EU * * @param array $result Decision result * @param string $billing Billing country * @param string $shipping Shipping country * @param string $vat_id Customer Tax ID * @param string $destination Destination country * * @return array Modified result */function my_vat_exempt_result( array $result, string $billing, string $shipping, string $vat_id, string $destination ): array { // Switzerland and Norway - always exempt if ( in_array( $destination, array( 'CH', 'NO' ), true ) ) { return array( 'exempt' => true, 'reason' => 'export', ); }
return $result;}add_filter( 'wpify_woo_icdic_vat_exempt_result', 'my_vat_exempt_result', 10, 5 );wpify_woo_icdic_pre_vies_validation
Section titled “wpify_woo_icdic_pre_vies_validation”Bypass VIES validation and return custom result. Called before VIES query.
apply_filters( 'wpify_woo_icdic_pre_vies_validation', $pre_result, $dic );| Parameter | Type | Description |
|---|---|---|
$pre_result | bool|null | null = continue with VIES, true/false = bypass |
$dic | string | Tax ID to validate (including country prefix) |
Return value:
true- Tax ID is valid (bypass VIES)false- Tax ID is invalid (bypass VIES)null- Continue with normal VIES validation
Example:
/** * Skip VIES for test Tax IDs * * @param bool|null $pre_result Previous result * @param string $dic Tax ID to validate * * @return bool|null Result or null to continue */function my_skip_vies_for_test( $pre_result, string $dic ) { // Skip VIES for test Tax IDs if ( str_starts_with( $dic, 'TEST' ) ) { return true; // Consider as valid }
// Skip VIES during outage - accept based on format if ( defined( 'VIES_FALLBACK' ) && VIES_FALLBACK ) { if ( preg_match( '/^[A-Z]{2}[0-9A-Z]+$/', $dic ) ) { return true; } }
return null; // Continue with VIES validation}add_filter( 'wpify_woo_icdic_pre_vies_validation', 'my_skip_vies_for_test', 10, 2 );wpify_woo_icdic_vies_validation_result
Section titled “wpify_woo_icdic_vies_validation_result”Modifies VIES validation result after it’s performed.
apply_filters( 'wpify_woo_icdic_vies_validation_result', $is_valid, $dic );| Parameter | Type | Description |
|---|---|---|
$is_valid | bool | VIES validation result |
$dic | string | Tax ID that was validated |
Return value: bool - Modified validation result
Example:
/** * Log VIES results * * @param bool $is_valid Validation result * @param string $dic Validated Tax ID * * @return bool Unchanged result */function my_log_vies_result( bool $is_valid, string $dic ): bool { error_log( sprintf( 'VIES validation for %s: %s', $dic, $is_valid ? 'valid' : 'invalid' ) );
return $is_valid;}add_filter( 'wpify_woo_icdic_vies_validation_result', 'my_log_vies_result', 10, 2 );wpify_woo_add_ic_dic_to_address
Section titled “wpify_woo_add_ic_dic_to_address”Controls whether Company ID/Tax ID is added to formatted address (emails, customer account).
apply_filters( 'wpify_woo_add_ic_dic_to_address', $add );| Parameter | Type | Description |
|---|---|---|
$add | bool | Whether to add Company ID/Tax ID to address (default true) |
Return value: bool - Whether to add to address
Example:
/** * Don't add Company ID/Tax ID to formatted address * * @param bool $add Whether to add * * @return bool Modified value */function my_hide_ic_dic_in_address( bool $add ): bool { return false;}add_filter( 'wpify_woo_add_ic_dic_to_address', 'my_hide_ic_dic_in_address' );Integration with Invoicing Plugins
Section titled “Integration with Invoicing Plugins”Displaying Reverse Charge Note on Invoice
Section titled “Displaying Reverse Charge Note on Invoice”The module does not automatically display notes on invoices. This must be handled by your invoicing plugin based on meta data.
Integration with WPify Woo Fakturoid
Section titled “Integration with WPify Woo Fakturoid”If you use the WPify Woo Fakturoid plugin, Reverse Charge and export notes are automatically processed based on meta data from this module.
Custom Invoicing Plugin
Section titled “Custom Invoicing Plugin”Example integration for custom invoicing solution:
/** * Add VAT note to invoice * * @param WC_Order $order Order * * @return void */function my_invoice_vat_note( WC_Order $order ): void { $is_exempt = wc_string_to_bool( $order->get_meta( 'is_vat_exempt' ) ); $reason = $order->get_meta( '_wpify_vat_exempt_reason' );
if ( ! $is_exempt ) { return; }
$notes = array( 'reverse_charge' => 'Reverse charge - VAT to be paid by the recipient pursuant to Art. 196 of Directive 2006/112/EC', 'export' => 'VAT exempt - supply of goods to third country', );
if ( isset( $notes[ $reason ] ) ) { echo '<p class="tax-note">' . esc_html( $notes[ $reason ] ) . '</p>'; }}add_action( 'my_invoice_footer', 'my_invoice_vat_note' );Integration with WooCommerce PDF Invoices & Packing Slips
Section titled “Integration with WooCommerce PDF Invoices & Packing Slips”/** * Add VAT note to WCPDF invoice * * @param string $document_type Document type * @param WC_Order $order Order * * @return void */function my_wcpdf_vat_note( string $document_type, WC_Order $order ): void { if ( $document_type !== 'invoice' ) { return; }
$is_exempt = wc_string_to_bool( $order->get_meta( 'is_vat_exempt' ) ); $reason = $order->get_meta( '_wpify_vat_exempt_reason' );
if ( ! $is_exempt ) { return; }
$notes = array( 'reverse_charge' => __( 'Reverse charge - VAT to be paid by recipient', 'my-plugin' ), 'export' => __( 'VAT exempt - export outside EU', 'my-plugin' ), );
if ( isset( $notes[ $reason ] ) ) { echo '<tr class="vat-exempt-note"><td colspan="3">' . esc_html( $notes[ $reason ] ) . '</td></tr>'; }}add_action( 'wpo_wcpdf_after_order_data', 'my_wcpdf_vat_note', 10, 2 );REST API
Section titled “REST API”The module adds REST API endpoint for Company ID and Tax ID validation:
POST /wp-json/wpify-woo/v1/ic-dic/validate| Parameter | Type | Required | Description |
|---|---|---|---|
ic | string | No | Company ID to validate (ARES) |
dic | string | No | Tax ID to validate (VIES) |
country | string | Yes | Country code (ISO 3166-1 alpha-2) |
Request example:
fetch('/wp-json/wpify-woo/v1/ic-dic/validate', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ ic: '12345678', country: 'CZ' })}).then(response => response.json()).then(data => console.log(data));CSS Classes
Section titled “CSS Classes”| Class | Description |
|---|---|
vat-exempt | Added to order in order list |
wpify-woo-ic-dic__toggle | ”I’m buying as a company” checkbox |
wpify-woo-ic-dic__company_field | Business fields (hidden when not checked) |
wpify-woo-ic--validate | Company ID field with ARES validation |
wpify-woo-vies--validate | Tax ID field with VIES validation |
JavaScript Events
Section titled “JavaScript Events”// After successful ARES data loaddocument.addEventListener('wpify_woo_ares_loaded', function(e) { console.log('ARES data:', e.detail);});
// After Tax ID VIES validationdocument.addEventListener('wpify_woo_vies_validated', function(e) { console.log('VIES result:', e.detail.valid);});Where to Place Code
Section titled “Where to Place Code”You can place custom functions:
- In your child theme’s
functions.php - Using the Code Snippets plugin
- In a custom plugin