Skip to content

Instantly share code, notes, and snippets.

@geekontheroad
Last active August 11, 2023 04:33
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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