WordPress EU VAT Helpers
, (*1)
WordPress helper shortcodes to display prices including applicable VAT rate for the user's location (based on IP address), (*2)
This WordPress plugin is basically a wrapper around the nifty mpociot/vat-calculator library. Use at your own risk for the following:, (*3)
- Format number as localized currency, adding VAT according to the rate of the visitor's country
- Display tax rate of the visitor's coutry
- Display the visitor's country
- Conditionally show/hide elements based on whether EU VAT is applicable in the visitor's country
Installation
- Recommended (most frequent updates):
composer require sehrgut/wp-eu-vat-helpers
- Alternative (possibly outdated): Via WordPress plugin directory or zip download, you know that stuff for sure…
Available Shortcodes
Shortcode Usage
[localize_currency]
Add EU VAT to value and format the result as currency., (*4)
Example:, (*5)
[localize_currency value="133.42" currency="EUR"]
Attributes:, (*6)
Attribute |
Required |
Default |
Effect |
value |
required |
– |
The amount to format |
currency |
optional |
'EUR' |
Currency as three-letter ISO-4217 code |
country |
optional |
based on user's IP address |
Override the country for which to apply taxes and adapt the format (two-letter ISO-3166-1 alpha-2 code) |
[vat_rate]
Display the EU VAT rate applicabe in the current user's country in percent., (*7)
Example:, (*8)
[vat_rate]
Attributes:, (*9)
Attribute |
Required |
Default |
Effect |
country |
optional |
based on user's IP address |
Override the country whose VAT rate to display (two-letter ISO-3166-1 alpha-2 code) |
[ip_country]
Display the current user's country based on their IP address., (*10)
Example:, (*11)
[ip_country]
Attributes: none, (*12)
[if_taxable]
Condtitionally display a piece of content if EU VAT is applicable in the current user's country., (*13)
Example:, (*14)
[if_taxable]Echo something[/if_taxable]
Attributes:, (*15)
Attribute |
Required |
Default |
Effect |
country |
optional |
based on user's IP address |
Override the country for which to check (two-letter ISO-3166-1 alpha-2 code) |
[unless_taxable]
Condtitionally display a piece of content if EU VAT is not applicable in the current user's country. (Inverse of if_taxable
), (*16)
Example:, (*17)
[unless_taxable]Echo something[/unless_taxable]
Attributes:
, (*18)
Attribute |
Required |
Default |
Effect |
country |
optional |
based on user's IP address |
Override the country for which to check (two-letter ISO-3166-1 alpha-2 code) |
Devlopment / Testing
# Install
git clone git@github.com/sehrgutesoftware/wp-eu-vat-helpers.git
cd wp-eu-vat-helpers
composer install
# Test
composer unit
composer integration
Support
Please use Github Issues for Questions, Bug reports, Feature suggestions and everything else., (*19)
Compatibility
This plugin was tested with WordPress 4.8.x and PHP 7.1 & 7.2, (*20)
License
Copyright 2017 Sehr gute GmbH – licensed under the MIT License., (*21)