Automatic Default Tax Rule on Product Creation
Install and configure automatic tax rules group assignment on every PrestaShop product creation.
What this module does
Since PrestaShop 1.7, a newly created product has no tax rule: the Tax rule field in the Pricing tab stays on “No tax” until you change it by hand. On an active catalog the oversight happens fast — and a product published without VAT throws off both the tax-inclusive price shown in your shop and your accounting.
This module automatically applies the tax rules group of your choice to every product created, with no manual step. An “only fill when empty” mode makes sure an already chosen rule is never overwritten.
Requirements
- PrestaShop 8.0 to 9.x
- PHP 7.4 to 8.3
- At least one active tax rules group configured under International > Taxes > Tax Rules
The module does not create any tax rule. It simply applies a rule that already exists in your shop. If your tax rules list is empty, create one before installing the module.
Installation
- Download the ZIP archive from your DataFirefly customer account.
- In the PrestaShop back office, go to Modules > Module Manager.
- Click Upload a module in the top right, then drop the ZIP file.
- Once installation completes, click Configure.
Important: until you pick a tax rules group in the configuration, the module deliberately stays inactive. This is a safeguard so it never applies an unwanted rule right after installation.
Configuration
The configuration page has two settings.
Tax rules group to assign
A drop-down lists every active tax rules group in your shop (for example “FR TVA 20%”). Pick the one that should be applied by default to new products.
The first entry in the list is “Do nothing (disabled)”. Select it if you want to temporarily suspend the module without uninstalling it.
Override existing value
This switch controls how the module behaves when a product already has a tax rule at creation time.
- Yes (default): the configured group is always applied, whatever the existing value.
- No: the group is only applied when the product has no tax rule at all. An existing value is never modified.
Set this option to No if you regularly duplicate already correctly configured products: copies will then keep the source product’s tax rule.
Click Save to confirm. The module is active immediately.
How it works
The module hooks into actionObjectProductAddAfter, fired by PrestaShop right after a new product row is inserted into the database. It then writes the id_tax_rules_group field into the product and product_shop tables.
Compatibility with product page v2
The new PrestaShop 8 product page works differently from the old one: as soon as you click New product, PrestaShop immediately creates a temporary product (sometimes called a “ghost product”) before you have typed anything at all. That product only shows up in the catalog after the first save.
This is exactly the moment the module steps in. The tax rule is therefore written to the database before the form is even displayed, and the Pricing tab shows the correct group straight away.
Technical note. The actionProductAdd hook, despite its name, is not fired on normal product creation: the PrestaShop core only calls it when a product is duplicated. That is why this module uses the generic actionObjectProductAddAfter hook, which correctly covers every creation path.
Targeted database write
The module updates only the id_tax_rules_group column, through a direct SQL query. It does not call Product::update(), which avoids needlessly firing update hooks on a still-empty product. No other product field is touched, and no core override is added.
Supported creation paths
| Creation method | Rule applied |
|---|---|
| Manual creation in the back office (product page v2) | Yes |
| Duplicating an existing product | Yes (can be disabled via the override option) |
| CSV import | Yes |
| Creation through the Webservice / API | Yes |
| Products that already existed before installation | No — the module only acts at creation time |
The module does not retroactively fix products already present in your catalog. For those, use PrestaShop’s native bulk edit or a bulk update module.
Multistore
The id_tax_rules_group field is shop-specific. The module therefore writes the value into the product table as well as product_shop, on the shop scope matching the product’s creation context.
The tax rules group chosen in the configuration is, however, shared across the whole installation. If your shops need different tax rules, apply the most common one and adjust exceptions manually.
Troubleshooting
The tax rule is not applied to new products
Check in this order:
- Is a group actually selected? Open the module configuration: if the list shows “Do nothing (disabled)”, the module is inactive by design. Pick a group and save.
- Is the hook properly registered? If you updated the module from version 1.0.0, the hook it uses has changed. Copying files over is not enough: uninstall then reinstall the module from the Module Manager so PrestaShop registers the new hook.
- Is the cache cleared? Go to Advanced Parameters > Performance and clear the cache.
- Does the tax rules group still exist? If the selected group has since been deleted, the module does nothing, as a safeguard. Select another one.
A duplicated product loses its original tax rule
This is the expected behaviour when Override existing value is enabled: the default group is reapplied to the copy. Set the option to No so duplicates keep the source product’s rule.
The tax-inclusive price does not update in the form
The tax-inclusive price is computed browser-side from the selected tax rule. Reload the product page: since the rule is correctly stored in the database, the Pricing tab will show the right group and recompute the price.
Uninstalling
From the Module Manager, click Uninstall. The module deletes its two configuration keys and unregisters from hooks. This module creates no database table, and tax rules already applied to your products are left untouched.
Version history
1.1.0
- Switched to the
actionObjectProductAddAfterhook to cover creation through product page v2 (temporary product) - Confirmed compatibility with PrestaShop 8 and 9
1.0.0
- Initial release: automatic tax rules group assignment on creation
- Configurable default group and override mode