Skip to content

Instantly share code, notes, and snippets.

@geekontheroad
Last active August 11, 2023 04:33
Show Gist options
  • Save geekontheroad/a270f59f0ddd7d31067b4437c565c441 to your computer and use it in GitHub Desktop.
Save geekontheroad/a270f59f0ddd7d31067b4437c565c441 to your computer and use it in GitHub Desktop.
This snippet is made for the EU VAT for Gravity Forms. It can apply the tax rate of the default country to all other EU countries.
<?php
/**
* Snippet to apply the tax rate of the base country to ALL EU countries
*
* @param Int $rate
* @param string $country_code the 2 digit ISO code of the country *
* @return Int $rate
* @version 1.0
* @link https://geekontheroad.com/eu-vat-for-gravity-forms/
* @author Johan dhollander
*
*
* INSTRUCTIONS
* 1. Copy this whole snippet excluding the beginning <?php tag
* 2. Change the " 1 " in the below line to your form ID or remove " _1 " to apply to all forms
**/
add_filter("gotreu_standard_vat_rate_1" , "gotreu_default_to_base_country_vat", 10,2);
function gotreu_default_to_base_country_vat( $rate , $country_code) {
$class = gotrgf_euvat_addon();
$settings = $class->get_plugin_settings();
$base_country = $settings["eu_vat_default_country"];
$explode = explode(":",$base_country);
$rate = intval($explode[1]);
return $rate;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment