Title: tjanson's Replies | WordPress.org

---

# tjanson

  [  ](https://wordpress.org/support/users/tjanson/)

 *   [Profile](https://wordpress.org/support/users/tjanson/)
 *   [Topics Started](https://wordpress.org/support/users/tjanson/topics/)
 *   [Replies Created](https://wordpress.org/support/users/tjanson/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/tjanson/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/tjanson/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/tjanson/engagements/)
 *   [Favorites](https://wordpress.org/support/users/tjanson/favorites/)

 Search replies:

## Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Fast Page & Post Duplicator] Conflict with WooCommerce Smart Coupons plugin](https://wordpress.org/support/topic/conflict-with-woocommerce-smart-coupons-plugin/)
 *  Thread Starter [tjanson](https://wordpress.org/support/users/tjanson/)
 * (@tjanson)
 * [5 months ago](https://wordpress.org/support/topic/conflict-with-woocommerce-smart-coupons-plugin/#post-18843576)
 * [https://woocommerce.com/products/smart-coupons/](https://woocommerce.com/products/smart-coupons/)
   
   Thanks to you, Thomas
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Price Based on Country for WooCommerce] Plugin fails if country has VAT-free region](https://wordpress.org/support/topic/plugin-fails-if-country-has-vat-free-region/)
 *  Thread Starter [tjanson](https://wordpress.org/support/users/tjanson/)
 * (@tjanson)
 * [7 months ago](https://wordpress.org/support/topic/plugin-fails-if-country-has-vat-free-region/#post-18776994)
 * Hola Oscar!
 * Thank you very much for your reply.
 * You guessed 4x right regarding my settings.
 * But by now I found a very good solution thanks to combination of your great plug-
   in and some custom code.
 * You plug-in does a great job, allowing me to:
 * – Advertise one price incl. shipping all around the EU, while
   – offering non-
   EU customers a reduced priceI only had to adjusted it so I don’t screw your compatriots
   from the Canary Islands 🙂I was actually close to making them their own country,
   but ChatGPT finally pulled it off right before I lost my belief in it.
 *  I looked a bit into your solution and wander: once you make the Canary Islands,
   a country property, do you really still need all this calculating? I would simply
   give the product the same absolute prize I charge e.g. Andorra. I only have one
   product for now with not too many following, so maybe that’s simply easier in
   my case.
   Wishing you all the best and thank you again for your help!
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Price Based on Country for WooCommerce] Plugin fails if country has VAT-free region](https://wordpress.org/support/topic/plugin-fails-if-country-has-vat-free-region/)
 *  Thread Starter [tjanson](https://wordpress.org/support/users/tjanson/)
 * (@tjanson)
 * [7 months ago](https://wordpress.org/support/topic/plugin-fails-if-country-has-vat-free-region/#post-18776184)
 *  I asked ChatGPT:
   With a little back-and-forth, it was able to give me the following
   code that is placed at the bottom of the child theme’s functions.php:– – – snip–––
 * /**
    - Apply non-VAT price for special VAT-exempt regions everywhere
      */function apply_vat_exempt_price(
      $price, $product) { if (!WC()->customer) return $price; $postcode = WC()->
      customer->get_shipping_postcode();$country = WC()->customer->get_shipping_country();//
      VAT-exempt regions$vat_exempt_regions = [‘ES’ => [’35’,’38’], // Canary Islands‘IT’
      => [‘23030′,’23041′,’22061’], // Livigno + Campione d’Italia‘DE’ => [‘27498’],//
      Helgoland]; foreach ($vat_exempt_regions as $c => $codes) {if ($country ==
      = $c) {foreach ($codes as $code) {if (strpos($postcode, $code) === 0) {return
      72; // <– your non-VAT price}}}} return $price;}
 * // Apply everywhere a product price is fetched
   add_filter(‘woocommerce_product_get_price’,‘
   apply_vat_exempt_price’, 20, 2);add_filter(‘woocommerce_product_get_regular_price’,‘
   apply_vat_exempt_price’, 20, 2);add_filter(‘woocommerce_product_get_sale_price’,‘
   apply_vat_exempt_price’, 20, 2);– – – snap – – –
 * On page results:
   1. Switzerland / postal code 12345: Must display 72€ / no VAT:
   OK2. Spain / postal code 12345: Must display 98€ / 21% Spanish VAT: OK3. Spain/
   postal code 38912: Must display 72€ / no VAT: OK
 * Furthermore, I completed an order for scenario 3 and it makes it correctly to
   the WooCommerce > Orders backend. So this is not only browser-side cosmetics.
   
   I have no clue of coding PHP, I don’t even really understand HTML, CSS, but I
   think this took about an hour. Maybe there’s still a back hidden somewhere, but
   I thought I post this before I forget about it. Maybe somebody can make good 
   use of it as well.

Viewing 3 replies - 1 through 3 (of 3 total)