Skip to content

Instantly share code, notes, and snippets.

@dwanjuki
Created June 30, 2026 08:28
Show Gist options
  • Select an option

  • Save dwanjuki/fbce909231aadf2ac69ae3ad6f0ff228 to your computer and use it in GitHub Desktop.

Select an option

Save dwanjuki/fbce909231aadf2ac69ae3ad6f0ff228 to your computer and use it in GitHub Desktop.
VAT Tax Add On: Apply tax for ALL UK customers
<?php
/**
* Apply tax for ALL UK customers
*
* Requires VAT Tax Add On
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmprovat_set_uk_vat_rate( $rates ) {
$rates['GB'] = 0.20; // 20% UK VAT
return $rates;
}
add_filter( 'pmpro_vat_by_country', 'my_pmprovat_set_uk_vat_rate' );
function my_pmprovat_disable_uk_vat_exemption( $tax, $values, $vat_rate, $vat_number, $eucountry, $bstate ) {
// Only affect UK customers.
if ( 'GB' !== $eucountry ) {
return $tax;
}
// If a rate was already applied, no VAT number was used — leave it alone.
if ( ! empty( $vat_rate ) ) {
return $tax;
}
// Rate is 0 for GB, meaning the VAT number exemption was granted. Re-apply UK VAT.
if ( function_exists( 'pmprovat_getTaxRate' ) && ! empty( $values['price'] ) ) {
$uk_rate = pmprovat_getTaxRate( 'GB' ); // pulls 0.20 from the plugin's own rate table
if ( ! empty( $uk_rate ) ) {
$tax += round( (float) $values['price'] * $uk_rate, 2 );
}
}
return $tax;
}
add_filter( 'pmprovat_calculated_taxes', 'my_pmprovat_disable_uk_vat_exemption', 10, 6 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment