Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

VAT note under prices (EU)

Under every price: “Includes 24% VAT, plus shipping” (or “Excludes VAT” when the shop shows prices without tax), with the rate for the customer’s country, as EU price rules expect.

  • Type PHP
  • Runs Everywhere (runs as WordPress loads)
  • Needs WooCommerce
  • Category WooCommerce
  • Tested with WordPress 7.1, WooCommerce 11.1
PHP
<?php

// A page with your shipping costs, to link "plus shipping" to (its ID), or 0.
$shipping_page = 0;

add_filter(
	'woocommerce_get_price_html',
	static function ( $html, $product ) use ( $shipping_page ) {
		if ( '' === $html || ( is_admin() && ! wp_doing_ajax() ) || ! wc_tax_enabled() || ! $product instanceof WC_Product ) {
			return $html;
		}
		if ( 'taxable' !== $product->get_tax_status() ) {
			$note = 'No VAT';
		} elseif ( 'incl' === get_option( 'woocommerce_tax_display_shop' ) ) {
			// The rate for the customer's location (the shop's until they give an address).
			$rates = WC_Tax::get_rates( $product->get_tax_class() );
			$rate  = $rates ? (float) reset( $rates )['rate'] : 0;
			$note  = $rate > 0 ? sprintf( 'Includes %s%% VAT', wc_format_localized_decimal( round( $rate, 2 ) ) ) : 'Includes VAT';
		} else {
			$note = 'Excludes VAT';
		}
		if ( $product->needs_shipping() ) {
			$shipping = 'plus shipping';
			$note    .= ', ' . ( $shipping_page ? '<a href="' . esc_url( get_permalink( $shipping_page ) ) . '">' . $shipping . '</a>' : $shipping );
		}
		return $html . ' <small class="vat-note">' . $note . '</small>';
	},
	10,
	2
);

Good to know

Needs taxes switched on in WooCommerce > Settings. To link “plus shipping” to your shipping page, put its ID in $shipping_page. Works in classic templates and the product blocks.

In these packs

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.