Hi Everyone,
This is an update regarding a recent forum issue, which has now been addressed via a support ticket. The following clarification and solution are provided for reference.
The behavior you encountered is the default way WooCommerce handles VAT-exempt orders: when an order is marked as VAT-exempt, WooCommerce removes the tax line entirely instead of displaying a 0% rate. This can cause issues with certain accounting software.
To ensure compatibility, We’ve prepared a PHP snippet that automatically adds a 0% VAT tax line to VAT-exempt orders. You can add this code to your theme’s functions.php file or use a “Code Snippets” plugin.
add_action( 'woocommerce_checkout_order_processed', function ( $order_id ) {
if ( ! $order_id ) {
return;
}
$order = wc_get_order( $order_id );
if ( ! $order ) {
return;
}
// Check if VAT-exempt
if ( $order->get_meta( 'is_vat_exempt' ) === 'yes' ) {
// Avoid duplicates
foreach ( $order->get_items( 'tax' ) as $item ) {
if ( $item->get_name() === 'EU VAT (Exempt)' ) {
return; // Already added
}
}
// Create 0% VAT tax item
$item = new WC_Order_Item_Tax();
$item->set_name( 'EU VAT (Exempt)' );
$item->set_label( 'VAT' );
$item->set_tax_total( 0 );
// Attach to order
$order->add_item( $item );
$order->save();
}
}, 20 );
Thank you!
Best regards,
Taha