VAT is removed instead of being 0%

Forums WooCommerce EU & UK VAT Numbers Validation – Support Forum VAT is removed instead of being 0%

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #177887
    Sam De Decker
    Participant

    Hi,

    I see that the VAT is being completely removed when a customer buys with a VAT number while it should be 0% instead.

    Is there any way to fix this?

    Thank you,

    sam

    #178865
    Taha
    Moderator
    Plugin Support

    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

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.