Advertisement
businessdad

WooCommerce Tax Display - Hide "I'm VAT exempt" for non-EU

Jan 25th, 2018
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.56 KB | None | 0 0
  1. /**
  2.  * Aelia Tax Display by Country for WooCommerce - Hide the "I'm VAT exempt" field from the country selector widget for
  3.  * non-EU visitors.
  4.  *
  5.  * HOW TO USE THIS CODE
  6.  * Add the code to the bottom of your theme's functions.php file (see https://www.skyverge.com/blog/add-custom-code-to-wordpress/).
  7.  * The code will automatically check if visitor's country is in the EU and, if not, it will hide the "I'm VAT exempt" checkbox.
  8.  *
  9.  * GPL DISCLAIMER
  10.  * This code is provided as is, without any explicit or implicit warranty, to the extent permitted by applicable law.
  11.  * Except when otherwise stated in writing the copyright holders and/or other parties provide the program "as is"
  12.  * without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of
  13.  * merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the program
  14.  * is with you. should the program prove defective, you assume the cost of all necessary servicing, repair or correction.
  15.  *
  16.  * Need a consultation, or assistance to customise this code? Find us on Codeable: https://aelia.co/hire_us
  17.  */
  18. add_filter('wc_aelia_tdbc_country_selector_widget_setting', function($value, $setting, $default) {
  19.   if($setting === 'tax_exempt_flag_enabled') {
  20.     $customer_country = isset($_COOKIE['aelia_customer_country']) ? $_COOKIE['aelia_customer_country'] : '';
  21.  
  22.     if(!in_array($customer_country, WC()->countries->get_european_union_countries('eu_vat'))) {
  23.       $value = false;
  24.     }
  25.   }
  26.  
  27.   return $value;
  28. }, 10, 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement