Skip to content

For Developers

This section is intended for developers who want to integrate the module with custom solutions or invoicing plugins.

Meta keyDescriptionExample
_billing_icCompany ID (identification number)12345678
_billing_dicTax ID (tax identification number)CZ12345678
_billing_dic_dphVAT ID (Slovakia only)SK1234567890
Meta keyDescriptionValues
is_vat_exemptWooCommerce standard - VAT exemptionyes / no
_wpify_vat_exempt_reasonExemption reasondomestic, export, reverse_charge, legacy, standard
$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' );
Meta keyDescription
billing_icCustomer Company ID
billing_dicCustomer Tax ID
billing_dic_dphCustomer VAT ID (SK)
// 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 );

Modifies the list of EU countries for Reverse Charge calculation.

apply_filters( 'wpify_woo_icdic_eu_country_codes', $eu_countries );
ParameterTypeDescription
$eu_countriesarrayArray 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' );

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 );
ParameterTypeDescription
$is_validboolValidation result (from VIES or basic check)
$vat_idstringTax 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 );

Overrides destination country used for VAT calculation.

apply_filters( 'wpify_woo_icdic_destination_country', $destination_country, $billing_country, $shipping_country, $shop_country );
ParameterTypeDescription
$destination_countrystringCalculated destination country (per WooCommerce settings)
$billing_countrystringCustomer billing country code
$shipping_countrystringCustomer shipping country code
$shop_countrystringShop 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 );

Overrides VAT exemption decision.

apply_filters( 'wpify_woo_icdic_vat_exempt_result', $result, $billing_country, $shipping_country, $vat_id, $destination_country );
ParameterTypeDescription
$resultarrayResult: ['exempt' => bool, 'reason' => string]
$billing_countrystringBilling country code
$shipping_countrystringShipping country code
$vat_idstringCustomer Tax ID
$destination_countrystringDestination 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 EU
  • reverse_charge - EU Reverse Charge (B2B within EU)
  • legacy - Exempted via deprecated setting
  • standard - 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 );

Bypass VIES validation and return custom result. Called before VIES query.

apply_filters( 'wpify_woo_icdic_pre_vies_validation', $pre_result, $dic );
ParameterTypeDescription
$pre_resultbool|nullnull = continue with VIES, true/false = bypass
$dicstringTax 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 );

Modifies VIES validation result after it’s performed.

apply_filters( 'wpify_woo_icdic_vies_validation_result', $is_valid, $dic );
ParameterTypeDescription
$is_validboolVIES validation result
$dicstringTax 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 );

Controls whether Company ID/Tax ID is added to formatted address (emails, customer account).

apply_filters( 'wpify_woo_add_ic_dic_to_address', $add );
ParameterTypeDescription
$addboolWhether 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' );

The module does not automatically display notes on invoices. This must be handled by your invoicing plugin based on meta data.

If you use the WPify Woo Fakturoid plugin, Reverse Charge and export notes are automatically processed based on meta data from this module.

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 );

The module adds REST API endpoint for Company ID and Tax ID validation:

POST /wp-json/wpify-woo/v1/ic-dic/validate
ParameterTypeRequiredDescription
icstringNoCompany ID to validate (ARES)
dicstringNoTax ID to validate (VIES)
countrystringYesCountry 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));
ClassDescription
vat-exemptAdded to order in order list
wpify-woo-ic-dic__toggle”I’m buying as a company” checkbox
wpify-woo-ic-dic__company_fieldBusiness fields (hidden when not checked)
wpify-woo-ic--validateCompany ID field with ARES validation
wpify-woo-vies--validateTax ID field with VIES validation
// After successful ARES data load
document.addEventListener('wpify_woo_ares_loaded', function(e) {
console.log('ARES data:', e.detail);
});
// After Tax ID VIES validation
document.addEventListener('wpify_woo_vies_validated', function(e) {
console.log('VIES result:', e.detail.valid);
});

You can place custom functions:

  • In your child theme’s functions.php
  • Using the Code Snippets plugin
  • In a custom plugin