Tax Rules
The Automatic tax rules module in Polski PRO assigns GTU codes, WooCommerce tax classes, categories, tags and product meta to WooCommerce products from condition and action rules you write. Rules run when a product is saved, on a daily, weekly or monthly schedule, or by hand, and every change is logged. The module is off by default.
How it works
Section titled "How it works"- Create a rule: name, match mode (all/any), conditions, actions, triggers, priority.
- The engine evaluates conditions against every product and applies actions when the rule matches.
- Every rule application is written to the audit log (who/what/when, dry run or live).
- Triggers:
- On product save - the rule runs after a product is created or updated.
- Daily - the rule runs in the nightly cron against the entire catalog.
- Weekly - runs once per week (WP-Cron).
- Monthly - runs once per 30 days (WP-Cron).
- Manual - the rule runs only when you click Run / Dry Run in the admin.
Configuration
Section titled "Configuration"Open WooCommerce > Tax Rules and click Add rule.
Rule fields
Section titled "Rule fields"| Field | Description |
|---|---|
| Name | Human-readable label (e.g. "Books -> GTU_12"). |
| Group (optional) | Free-form label used for filtering in the list. |
| Enabled | Toggle a rule off without deleting it. |
| Match mode | all - every condition must match, any - at least one must match. |
| Triggers | When the rule runs (save / daily / weekly / monthly / manual). |
| Priority | Execution order, ascending (default 10). |
Conditions
Section titled "Conditions"Format: field | operator | value | key (last field optional).
Fields: title, sku, short_description, description, price, regular_price, stock_quantity, stock_status, category, tag, type, attribute, tax_class, meta_field, gtu_code, taxonomy.
Rules saved with the older field name jpk_v7_code are read as gtu_code.
Operators: equals, not_equals, contains, not_contains, starts_with, ends_with, gt, gte, lt, lte, in, not_in, is_empty, is_not_empty.
The taxonomy field accepts any custom taxonomy; put the taxonomy slug in key and a comma-separated list of term IDs in value:
taxonomy | in | 12,34,56 | product_brandExamples:
title | contains | bookprice | gte | 100category | in | 42,56,78meta_field | equals | yes | _polski_tabletActions
Section titled "Actions"Format: action_type | value.
| Action | Description | Example |
|---|---|---|
set_gtu_code |
Assign a GTU code | set_gtu_code | GTU_06 |
remove_gtu_code |
Remove the GTU code | remove_gtu_code | |
set_tax_class |
Set a WooCommerce tax class | set_tax_class | reduced-rate |
add_category / remove_category |
Add or remove a category | add_category | 42 |
add_tag / remove_tag |
Add or remove a tag | add_tag | 77 |
set_meta_field |
Set a meta field, key:value |
set_meta_field | _polski_custom:flag |
delete_meta_field |
Delete a meta field | delete_meta_field | _polski_custom |
mark_receipt_with_nip |
Flag product as requiring receipt with NIP | mark_receipt_with_nip | 1 |
The GTU code is stored in the _polski_gtu_code product meta. Rules saved with the older actions set_jpk_v7_code and remove_jpk_v7_code run as set_gtu_code and remove_gtu_code.
A product flagged with mark_receipt_with_nip (meta _polski_receipt_requires_nip = 1) makes the NIP field required at checkout whenever it is in the cart, through the polski/nip_required filter of Polski (free).
Dry run and Audit log
Section titled "Dry run and Audit log"Each rule has Dry run (preview without writing) and Run now (apply to the whole catalog) actions. The Audit log tab shows the last 200 applications with timestamp, rule, product, match flag, dry-run flag and applied actions.
Smart Pickers (editor helper)
Section titled "Smart Pickers (editor helper)"At the top of the rule editor the Insert helper panel lets you add condition/action lines without looking up IDs by hand:
- Category - all
product_catterms (Select2). Buttons appendcategory | in | <ID>oradd_category | <ID>. - Tag - same for
product_tag. - Tax class - list of WooCommerce tax classes. Buttons append
set_tax_class | <slug>ortax_class | equals | <slug>. - GTU code - dropdown with
GTU_01toGTU_13. Buttons append the actionset_gtu_code | <CODE>or the conditiongtu_code | equals | <CODE>.
The textarea remains the source of truth - pickers only append lines.
Rule groups
Section titled "Rule groups"Each rule may carry an optional group label. Groups are used only for organizing and filtering rules in the admin; they do not affect execution.
Search and filters
Section titled "Search and filters"The rules list supports case-insensitive name search, status filter (enabled/disabled), trigger filter and group filter (visible only when groups exist).
Import and export rules
Section titled "Import and export rules"The Import / export tab lets you:
- Export all rules as a portable JSON file (format
polski.tax_rules, v1) for backup or migration. - Import a previously exported JSON file. Imports always append rules (never replace by ID), so you can safely merge rule sets from multiple stores.
WP-CLI
Section titled "WP-CLI"For large catalogs and automation:
# List ruleswp polski tax-rules listwp polski tax-rules list --format=json
# Dry-run rule #3wp polski tax-rules run 3 --dry-run
# Apply rule #3 with 100-item batcheswp polski tax-rules run 3 --batch-size=100
# Export rules to a filewp polski tax-rules export --file=/tmp/rules.json
# Import rules from a filewp polski tax-rules import /tmp/rules.jsonBulk action on the products list
Section titled "Bulk action on the products list"On the standard WooCommerce products list (wp-admin/edit.php?post_type=product) the Bulk actions dropdown exposes two entries:
- Apply tax rules - runs every enabled rule against the selected products.
- Dry-run tax rules - reports what would change, without writing.
After execution an admin notice shows the number of products processed, rule matches, and changes applied.
Integration
Section titled "Integration"The assigned GTU code (_polski_gtu_code) is read by:
- the PDF invoice template of Polski (free), which prints the code next to the line item
- not the Polski PRO PDF invoice: its TCPDF layout does not print GTU codes
- the FA(3) document sent to KSeF, which carries the GTU code on each line whose product has one
The same code can also be set by hand in the product editor of Polski (free).
Limits and performance
Section titled "Limits and performance"- The daily cron processes the catalog in batches of 50 products. It can be switched off with
run_daily= false in thepolski_tax_rulesoption (default true); weekly and monthly runs are always scheduled. - The monthly schedule is an interval of 30 days.
wp polski tax-rules runuses batches of 50 unless you pass--batch-size.- The audit log is capped at 10,000 rows; older entries are trimmed automatically.
- The engine guards against recursion: a rule will not re-trigger during its own internal product save.
Does the module set JPK_V7 codes separately from GTU codes?
Section titled "Does the module set JPK_V7 codes separately from GTU codes?"No. There is one GTU code per product, stored in _polski_gtu_code. Old rules that used set_jpk_v7_code or the jpk_v7_code condition are read as their GTU equivalents.
How do I test a rule without changing products?
Section titled "How do I test a rule without changing products?"Use Dry run on the rule, the Dry-run tax rules bulk action on selected products, or wp polski tax-rules run <id> --dry-run. Each reports matches and the changes it would make, and the audit log marks the entries as dry runs.
Will importing rules overwrite my existing ones?
Section titled "Will importing rules overwrite my existing ones?"No. Imported rules are always appended to the list. The file must be an export in the polski.tax_rules format.
Can I stop the nightly run on a large catalog?
Section titled "Can I stop the nightly run on a large catalog?"Yes. Set run_daily to false in the polski_tax_rules option, for example with wp option patch update polski_tax_rules run_daily 0, and the daily event is unscheduled. Rules with the Daily trigger then run only when started by hand.