Magento VAT and tax settings: single site and multisite
VAT in Magento 2.4.9, set up once for a single shop and then per website: tax rates for the UK, Germany and the Netherlands, one tax rule, prices entered and shown including VAT, a full tax summary in the cart, then the tax settings of each store with the scope switcher (website and store view), and Cross Border Trade per website for one gross price in every country. Tested on our three-website test shop from Lesson 11.
Four building blocks
| Block | Waar | Wat het is |
|---|---|---|
| Tax rate | Stores › Tax Zones and Rates | A country (optionally state and post code) and a percentage |
| Product tax class | On every product (Tax Class) | Taxable Goods by default |
| Customer tax class | On every customer group | Retail Customer by default, also for NOT LOGGED IN |
| Tax rule | Stores › Tax Rules | These rates, for these customer classes, on these product classes |
Standard rates used in the lesson: UK 20 % (GOV.UK: VAT rates), Germany 19 % en Netherlands 21 % (European Commission, Your Europe: VAT rules and rates). Reduced rates (food, books…) need their own product tax class, rates and rule.
Tax rates (CSV import)
The UK rate came from Lesson 4. For Germany and the Netherlands we import a CSV in System › Data Transfer › Import/Export Tax Rates (also at the bottom of Stores › Tax Rules › Add New Tax Rule). Same columns as Export Tax Rates; * means all states / post codes; an existing code is updated, not doubled. Optional extra columns named after store view codes hold the rate title per store view.
Code,Country,State,Zip/Post Code,Rate,Zip/Post is Range,Range From,Range To UK VAT,GB,*,*,20,,, Germany VAT,DE,*,*,19,,, Netherlands VAT,NL,*,*,21,,,
The tax rule
Stores › Tax Rules › Add New Tax Rule: Name VAT UK DE NL, Tax Rate UK VAT, Germany VAT, Netherlands VAT. Under Additional Settings: Customer Tax Class Retail Customer, Product Tax Class Taxable Goods (both preselected), Priority 0. Save Rule. Magento picks the rate whose country matches the customer’s address (or the default tax destination).
Single site settings
Stores › Configuration › Sales › Tax, scope Default Config:
| Groep | Instelling | Waarde in de video |
|---|---|---|
| Tax Classes | Tax Class for Shipping | None (shipping without VAT here; pick a class if your shipping is taxable) |
| Tax Classes | Default Tax Class for Product / Customer | Taxable Goods / Retail Customer |
| Calculation Settings | Tax Calculation Based On | Shipping Address |
| Calculation Settings | Catalog Prices / Shipping Prices | Including Tax (prices in the admin contain VAT) |
| Calculation Settings | Apply Customer Tax / Apply Discount On Prices | After Discount / Including Tax |
| Calculation Settings | Enable Cross Border Trade | No (see below) |
| Default Tax Destination Calculation | Default Country | United Kingdom: used until the customer gives an address (catalog, new cart) |
| Price Display Settings | Products / Shipping | Including Tax |
| Shopping Cart Display Settings | Prices, Subtotal, Shipping | Including Tax; Order Total Without Tax: Yes; Full Tax Summary: Yes |
| Orders, Invoices, Credit Memos | the same five | the same values |
#!/bin/bash
# MageBooster Lesson 12: VAT settings for a single site (Default Config), as in the admin (run on the server, in the Magento folder)
cd /var/www/magento
m() { sudo -u magento bin/magento config:set "$@"; }
m tax/calculation/price_includes_tax 1 # Catalog Prices: Including Tax
m tax/calculation/shipping_includes_tax 1 # Shipping Prices: Including Tax
m tax/calculation/discount_tax 1 # Apply Discount On Prices: Including Tax
m tax/defaults/country GB # Default Tax Destination: United Kingdom
m tax/display/type 2 # Display Product Prices In Catalog: Including Tax
m tax/display/shipping 2
for k in price subtotal shipping; do m tax/cart_display/$k 2; m tax/sales_display/$k 2; done
for k in grandtotal full_summary; do m tax/cart_display/$k 1; m tax/sales_display/$k 1; done
sudo -u magento bin/magento cache:flush
Scopes and the scope switcher
De scope switcher at the top left of Stores › Configuration picks what you edit: Default Config (all stores), a website or a store view. The label under each field name shows how far down it can be set. From Magento/Tax/etc/adminhtml/system.xml in 2.4.9:
| Label | Betekenis | Tax settings with this scope |
|---|---|---|
| [GLOBAL] | One value for the whole installation (Default Config only) | Default Tax Class for Product, Default Tax Class for Customer |
| [WEBSITE] | One value per website | Tax Class for Shipping, all Calculation Settings (incl. Catalog Prices and Enable Cross Border Trade) |
| [STORE VIEW] | One value per store view | Default Tax Destination Calculation, Price Display, Shopping Cart Display, Orders/Invoices/Credit Memos Display |
Below Default Config every field has a checkbox: Use Default Value on a website, Use Website on a store view. Ticked, the field inherits from the level above; untick it to give this website or store view its own value, then Save Config. A store-view field can also be set on the website: it then applies to all of the website’s store views. General › Country Options › Default Country is a store-view field too.
Tax settings per store
In the video, one store at a time: scope = the website for Calculation Settings, the tax destination and the default country, then scope = its store view for the display settings, Save Config each time. Then System › Cache Management › Flush Magento Cache (with Varnish this also purges the page cache).
| Setting (Stores › Configuration) | Scope | Set on | UK · Main Website | Duitsland | Nederland |
|---|---|---|---|---|---|
| Sales › Tax › Calculation Settings › Enable Cross Border Trade | website | website | No, later Yes | No, later Yes | No, later Yes |
| Sales › Tax › Calculation Settings › Catalog Prices, Shipping Prices | website | Default Config | Including Tax (inherited) | Including Tax (inherited) | Including Tax (inherited) |
| Sales › Tax › Default Tax Destination Calculation › Default Country | store view | website | United Kingdom (inherited) | Duitsland | Nederland |
| General › Country Options › Default Country | store view | website | United Kingdom (inherited) | Duitsland | Nederland |
| Sales › Tax › Price Display Settings (products, shipping) | store view | Default Config | Including Tax (Use Website) | Including Tax (Use Website) | Including Tax (Use Website) |
| Sales › Tax › Shopping Cart / Orders Display Settings | store view | Default Config | Including Tax, full tax summary | the same | the same |
Store views in our test shop: Default Store View (Main Website, www), Deutsch (Germany, de), Nederlands (Netherlands, nl). Why the default country too: the checkout address form starts with General › Default Country, the cart estimate with the tax destination; without both a German visitor starts with the United Kingdom. A store view could show prices differently (for example Excluding Tax for a trade shop): untick Use Website there. The same as a script:
#!/bin/bash
# MageBooster Lesson 12: the per-store settings of the video (admin: Stores › Configuration, scope switcher), as config:set.
# Website scope: tax destination + checkout country per website; the UK (Main Website) inherits GB from Default Config.
cd /var/www/magento
m() { sudo -u magento bin/magento config:set "$@"; }
m --scope=websites --scope-code=germany tax/defaults/country DE
m --scope=websites --scope-code=germany general/country/default DE
m --scope=websites --scope-code=netherlands tax/defaults/country NL
m --scope=websites --scope-code=netherlands general/country/default NL
# store views: display settings stay inherited (Use Website = including tax). A store view could override them, e.g.:
# m --scope=stores --scope-code=nl_nl tax/display/type 1 # 1 = Excluding Tax, 2 = Including Tax, 3 = both
# Cross Border Trade (one gross price in every country), per website:
for w in base germany netherlands; do m --scope=websites --scope-code=$w tax/calculation/cross_border_trade_enabled 1; done
sudo -u magento bin/magento cache:flush
Result on our test shop (travel mug, 24.00 including VAT in the admin, shipping origin United Kingdom from Lesson 4):
| www (UK) | de (Germany) | nl (Netherlands) | |
|---|---|---|---|
| Product price, Cross Border Trade Nee | €24.00 | €23.80 | €24.20 |
| Product price, Cross Border Trade Ja | €24.00 | €24.00 | €24.00 |
| Cart tax line (CBT Yes) | UK VAT (20%) €4.00 | Germany VAT (19%) €3.83 | Netherlands VAT (21%) €4.17 |
| Order total incl. / excl. tax (+ €5 flat rate) | €29.00 / €25.00 | €29.00 / €25.17 | €29.00 / €24.83 |
Cross Border Trade
With catalog prices including tax, Magento first takes the VAT out with the rate of its own origin (Shipping Settings › Origin, here the UK: 24.00 / 1.20 = 20.00 net), then adds the customer’s rate: 20.00 × 1.19 = 23.80, 20.00 × 1.21 = 24.20. Enable Cross Border Trade = Yes keeps the gross price the same in every country, and the VAT inside it changes. It is a website-scope setting: in the video it is switched on for each website (scope = website, untick Use Default Value, Yes, Save Config), then the cache is flushed. Setting it once at Default Config does the same for all websites that don’t override it.
B2B and the EU
Customers › Customer Configuration › Create New Account Options › Enable Automatic Assignment to Customer Group checks VAT IDs with the EU VIES service and moves customers into the groups you set (valid domestic, valid intra-EU, invalid, validation error). For sales to consumers in other EU countries above the EU-wide threshold, the customer’s country rate applies, declared through the One-Stop Shop (OSS). Which rules apply to your business is a question for your accountant.
Downloads
Problemen oplossen
| Symptoom | Oorzaak en oplossing |
|---|---|
| New Tax Rate form is empty | 2.4.9 + PHP 8.5 with more than one store view (Form.php:248 deprecation). Import the rates as CSV. |
| No tax in the cart | No rule for the customer class + product class + country, or the product has Tax Class None. |
| Price differs per country | Catalog prices include tax and Cross Border Trade is No: expected; enable Cross Border Trade for one gross price. |
| German site checkout starts with United Kingdom | Set General › Country Options › Default Country per website. |
| Old prices on the storefront | Full page cache / Varnish: System › Cache Management › Flush Magento Cache of bin/magento cache:flush. |
| A field is greyed out | Use Default Value / Use Website is ticked: untick it. A field missing in a scope is GLOBAL (or WEBSITE when a store view is selected). |
Volgende les
Lesson 13: OpenSearch, set up in the admin and tested on the server.
▶ Bekijk alle MageBooster-lessen op YouTube: alle lessen op volgorde · abonneer je op het kanaal
