How to add zero rated Tax/VAT for intra-community goods?

In order to add zero rated Tax/VAT for intra-community goods to your complete website use below filters. It will show the Tax/VAT on the cart and will permanently add it to the order and thus on the invoice.

/**
 * Add zero rated tax when vat exempt for intra-community goods.
 *
 * @param array   $tax_totals Tax totals.
 * @param WC_Cart $cart       WC cart.
 *
 * @return mixed
 */
function display_vat_exempt_intra_community_goods( $tax_totals, $cart ) {
	if ( empty( WC()->customer ) || ! WC()->customer->get_is_vat_exempt() ) {
		return $tax_totals;
	}

	$taxes = WC_Tax::get_rates( 'intra-community-goods' );

	foreach ( $taxes as $key => $tax ) {
		$code = WC_Tax::get_rate_code( $key );

		if ( $code || apply_filters( 'woocommerce_cart_remove_taxes_zero_rate_id', 'zero-rated' ) === $key ) {
			if ( ! isset( $tax_totals[ $code ] ) ) {
				$tax_totals[ $code ]         = new stdClass();
				$tax_totals[ $code ]->amount = 0;
			}
			$tax_totals[ $code ]->tax_rate_id      = $key;
			$tax_totals[ $code ]->is_compound      = WC_Tax::is_compound( $key );
			$tax_totals[ $code ]->label            = WC_Tax::get_rate_label( $key );
			$tax_totals[ $code ]->amount           += wc_round_tax_total( $tax );
			$tax_totals[ $code ]->formatted_amount = wc_price( $tax_totals[ $code ]->amount );
		}
	}

	return $tax_totals;
}
add_filter( 'woocommerce_cart_tax_totals', 'display_vat_exempt_intra_community_goods', 10, 2 );
/**
 * Add ICP VAT to order.
 *
 * @param WC_Order $order WC order object.
 * @param array    $data  data.
 */
function add_vat_exempt_intra_community_goods( $order, $data ) {
	if ( empty( WC()->customer ) || ! WC()->customer->get_is_vat_exempt() ) {
		return;
	}

	foreach ( WC_Tax::get_rates( 'intra-community-goods' ) as $tax_rate_id => $tax ) {
		if ( $tax_rate_id && apply_filters( 'woocommerce_cart_remove_taxes_zero_rate_id', 'zero-rated' ) !== $tax_rate_id ) {
			$item = new WC_Order_Item_Tax();
			$item->set_props(
				array(
					'rate_id'            => $tax_rate_id,
					'tax_total'          => WC()->cart->get_tax_amount( $tax_rate_id ),
					'shipping_tax_total' => WC()->cart->get_shipping_tax_amount( $tax_rate_id ),
					'rate_code'          => WC_Tax::get_rate_code( $tax_rate_id ),
					'label'              => WC_Tax::get_rate_label( $tax_rate_id ),
					'compound'           => WC_Tax::is_compound( $tax_rate_id ),
				)
			);

			// Add item to order and save.
			$order->add_item( $item );
		}
	}
}
add_action( 'woocommerce_checkout_create_order', 'add_vat_exempt_intra_community_goods', 10, 2 );