Shipping Rules, Restrictions and Surcharges for Magento 2
- Compatibility
- 2.4.9, 2.4.8, 2.4.7, 2.4.6, 2.4.5, 2.4.4, 2.4.3, 2.4.2, 2.4.1, 2.4.0, 2.3.7, 2.3.6, 2.3.5, 2.3.4
Description / Shipping Rules, Restrictions and Surcharges for Magento 2
MAGENTO 2 · SHIPPING METHODS · RESTRICTIONS · EXTRA FEE
Match shipping methods and costs to your real logistics.
Kowal Shipping Rules
Create custom shipping methods, conditional rates, and restrictions. Add fees for the cart or matching products and keep them accounted for in the order, invoice, and credit memo.
Magento Rule UI conditions · Product shipping types · Amasty migration
HOW IT WORKS IN PRACTICE
01 · Define the method and rates
Select the address, weight, quantity, and cart range.
02 · Add restrictions or a fee
Hide the method, show an error, or charge a fee.
03 · Check the order process
Verify checkout, invoice, and credit memo.
What does your store gain?
Explore the module features, use cases, and settings.
Advanced Magento 2 shipping rules
Kowal Shipping Rules lets you map your store's real logistics in Magento 2: custom shipping methods, conditional rates, availability restrictions, and additional fees.
Instead of manually correcting orders after purchase, show the customer the right shipping method and cost already during checkout.
Custom shipping methods
Handle pallet, local, oversized, specialized delivery, or other processes specific to your business.
Conditional rates
Build rules based on country, region, ZIP code, cart value, weight, and number of products.
Restrictions and Extra Fee
Hide unavailable options and charge fees for size, packaging, special handling, or a specific method.
One place for shipping logic
Combine methods, conditions, restrictions, and fees into one consistent process. This is especially useful for heavy or non-standard products, delivery zones, and stores with more complex logistics.
How do you implement a rule?
- Create a shipping method.
- Define the rate and the conditions for applying it.
- Add restrictions or an additional fee if needed.
- Test cart scenarios and delivery addresses.
FAQ
Can I create my own shipping methods?
Yes. The module is designed to build methods that match your store's real logistics scenarios.
Can rules depend on the address?
Yes, they can include, among other things, country, region, and ZIP code.
Can an additional fee be added?
Yes. Extra Fee can reflect, for example, the cost of packaging, size, or special handling.
Can a method be hidden under specific conditions?
Yes. Restrictions let you limit method availability depending on the rule configuration.
Methods, restrictions, and fees panel
Sales → Shipping Methods & Rules provides Shipping Methods, Shipping Restrictions, and Extra Fees. You enable the kowal_shippingrules carrier in Sales → Delivery Methods, and configure restrictions, fees, and debug in Sales → Shipping Methods & Rules.
Methods can be limited by Store View, customer groups, and conditions. The kowal_shipping_type attribute lets you differentiate product shipping methods and match rates in a mixed cart.
Fee and restriction modes
A restriction can hide a method or replace it with an error and message. Rules have priority and an option to stop further processing.
Extra Fee supports fixed and percent_subtotal, and charging once per cart, per_item, or per_matching_item. Fee tax depends on tax_mode and tax_class_id; amounts pass through quote, order, invoice, and creditmemo.
Diagnostics and checkout implementation
The kowal:shippingrules:stabilization:check command is a check without data modifications. A dedicated log is available in var/log/kowal_shipping_rules.log, and separate switches let you disable restrictions or fees.
The module adds the kowal_shipping_fee totals segment in standard checkout. With Hyvä Checkout and a custom summary, you need to connect its presentation and verify the final amounts.
Migration from Amasty
Normal operation does not require Amasty. The amasty:report and amasty:apply tools support migration of restrictions and Extra Fee through a report, dry-run, and preview.
Saving with --execute includes ready records; manual_review and unsupported remain for analysis. Migration does not disable source modules or switch traffic. Afterward, check the consistency of rules and cart results.
Installation via Composer
Package kowal/module-shipping-rules, module Kowal_ShippingRules. After configuring access to the Kowal repository, install the package, enable the module, update Magento, and clear the cache. In production, include compilation and static content deployment according to your store's process.
From configuration to results
1. Define the method and rates
Select the address, weight, quantity, and cart range.
2. Add restrictions or a fee
Hide the method, show an error, or charge a fee.
3. Check the order process
Verify checkout, invoice, and credit memo.
Shipping for a cart with different item sizes
You mark products with a shipping type and prepare rates for individual types. The method can combine the result as the highest cost, the sum, or the lowest rate.
A conditional fee can reflect additional packaging. You check the final amount for the address, cart, and selected method.
Map your store's shipping rules
Want to adapt the module to your store? Ask about implementing Kowal Shipping Rules and discuss the configuration or required extensions.
More Information
| Theme compatibility | Luma / Blank, KOWAL |
|---|
Questions and Answers
Can the module create custom shipping methods?
Can shipping methods be hidden?
Can extra fees be added?
Can restriction rules use product attributes?
Does the module support oversized products?
Is the module suitable for B2B stores?
Can the module replace several separate extensions?
Can store staff work with the module without a developer?
Module Installation Instructions
Kowal ShippingRules — installation, configuration, and user guide
Purpose of this document
This document describes the practical implementation and use of the Kowal_ShippingRules module in Magento 2. It is intended for people responsible for module installation, store configuration, implementation testing, and daily management of shipping rules.
The document covers:
- module installation,
- basic configuration,
- creating shipping methods,
- rate configuration,
- handling shipping method restrictions,
- handling additional Extra Fee charges,
- diagnostics,
- migration from Amasty modules,
- a post-implementation test checklist.
Basic information
Technical module name:
Kowal_ShippingRulesModule location:
vendor/kowal/module-shipping-rulesCarrier code:
kowal_shippingrulesThe shipping method code in checkout has the following format:
kowal_shippingrules_<kod_metody>Example:
kowal_shippingrules_dostawa_paletowaPre-installation requirements
Before installation, confirm that:
- the store runs on Magento 2.4.x,
- the environment uses PHP
>=8.1, - the
Kowal_Basemodule is available, - a backup of files and the database has been made,
- the implementation is performed first in a test or staging environment,
- after installation it will be possible to run
setup:upgradeandsetup:di:compile, - the tester has access to the admin panel and checkout.
Module installation
Installation via Composer
You will receive access credentials for the Composer repository (customer email address and license token) by email after purchase. They are also available in the customer panel after logging in at kowal.store. Replace TWOJ_EMAIL_KLIENTA with your account email address and TWOJ_TOKEN with the token you received. Run the commands in the Magento root directory.
composer config repositories.kowal composer https://repo.kowal.store
composer config http-basic.repo.kowal.store 'TWOJ_EMAIL_KLIENTA' 'TWOJ_TOKEN'
composer require kowal/module-shipping-rules2. Enable the module
bin/magento module:enable Kowal_ShippingRulesIf Kowal_Base is not enabled yet, enable it earlier or together with the module:
bin/magento module:enable Kowal_Base Kowal_ShippingRules3. Update the database
bin/magento setup:upgradeThis command creates the module tables and adds the columns required to support Extra Fee in quote, order, invoice, and creditmemo.
4. Compile DI
In production:
bin/magento setup:di:compile5. Clear the cache
bin/magento cache:flush6. Check module status
bin/magento module:status Kowal_ShippingRulesThe module should be listed as enabled.
Post-installation check
After installation, run diagnostics:
bin/magento kowal:shippingrules:stabilization:checkFull JSON variant:
bin/magento kowal:shippingrules:stabilization:check --jsonThe command is read-only and does not change data. It checks, among other things:
- the presence of module tables,
- the number of records,
- invalid conditions JSON,
- active methods without active rates,
- Extra Fee rules with tax class when tax mode is disabled.
If the command returns errors, do not switch the module to production use before they are explained.
Basic configuration
Carrier
Path in the Magento panel:
Stores / Configuration / Sales / Delivery Methods / Shipping Methods & RulesFields:
Enabled— enables or disables thekowal_shippingrulescarrier.Title— the method group name visible in checkout.Test Method Name— the name of the test configuration method.Test Method Price— the price of the test configuration method.Sort Order— the carrier order on the shipping methods list.Show Method If Not Applicable— whether to show an error when no methods are available.Displayed Error Message— the message when the method is not available.
Most important setting:
carriers/kowal_shippingrules/active = 1If the carrier is disabled, methods created in the module will not be available in checkout.
Diagnostics and emergency functions
Path in the Magento panel:
Stores / Configuration / Sales / Shipping Methods & RulesGeneral Diagnostics section:
Enable Debug Logging— saves decision details to the log.Shadow Mode— a mode prepared for comparing behavior during migration.
Restrictions section:
Enable Restrictions— enables or disables only restrictions.
Extra Fees section:
Enable Extra Fees— enables or disables only additional fees.Fee Tax Mode— defines how tax is handled for Extra Fee.
Available tax modes:
Do Not Calculate Tax— the module does not calculate tax on Extra Fee.Calculate by Fee Tax Class— the module calculates tax based on the tax class set on the fee rule.
Default, safe settings:
kowal_shippingrules/general/debug = 0kowal_shippingrules/general/shadow_mode = 0kowal_shippingrules/restrictions/enabled = 1kowal_shippingrules/fees/enabled = 1kowal_shippingrules/fees/tax_mode = noneModule menu in the panel
Path:
Sales / Shipping Methods & RulesAvailable sections:
Shipping Methods— shipping methods and rates,Shipping Restrictions— shipping method restrictions,Extra Fees— additional fees.
Managing shipping methods
When should you create a shipping method?
Create a shipping method when the store needs its own delivery option, for example:
- pallet delivery,
- special transport,
- local delivery,
- courier for oversized products,
- logistics pickup,
- a method available only for selected products or regions.
Creating a method
Go to:
Sales / Shipping Methods & Rules / Shipping MethodsThen select Add New or edit an existing method.
Typical method fields:
Is Active— whether the method is active.Code— the technical method code.Name— the name visible to the customer.Description— the method description.Sort Order— display order.Store Views— store view visibility.Customer Groups— customer group visibility.Conditions— method availability conditions.
Recommendations for the Code field:
- use lowercase letters,
- do not use Polish characters,
- do not use spaces,
- use underscores instead of spaces.
Examples:
dostawa_paletowatransport_specjalnykurier_gabarytdostawa_lokalnaThe full method code in checkout will have the carrier prefix:
kowal_shippingrules_dostawa_paletowaMethod rates
An active method should have at least one active rate. If the method has no matching rate, it will not appear in checkout.
A rate can depend on:
- country,
- region,
- ZIP code,
- cart value,
- weight,
- product quantity,
- shipping type,
- priority.
Price modes:
fixed— fixed price,percent_subtotal— percentage of subtotal.
Examples:
- price of PLN 29 for shipments up to 30 kg,
- price of PLN 149 for pallet delivery,
- 5% of cart value for special transport,
- a separate rate for selected ZIP codes.
Method conditions
Conditions define when the method should be available.
Examples:
- method available only for products from a selected category,
- method available only for a specific product attribute,
- method available only for a cart above a specific value,
- method available only for a selected delivery country.
If conditions are empty, the method is limited only by status, store view, customer group, and matching rate.
Managing shipping method restrictions
When should you use restrictions?
Restrictions are used to hide or block shipping methods that should not be available for a specific order.
Examples:
- hide parcel locker for oversized products,
- block international shipping for a selected category,
- show a message that express transport is unavailable for made-to-order products,
- hide a delivery method for a selected country.
Creating a restriction
Go to:
Sales / Shipping Methods & Rules / Shipping RestrictionsThen select Add New or edit an existing restriction.
Typical fields:
Is Active— whether the restriction is active.Name— internal name.Target Carrier— the carrier the restriction applies to.Target Method— the method the restriction applies to.Action— how it works.Message— customer-facing message.Priority— priority.Stop Processing— whether to stop further rule checking.Store Views— store view scope.Customer Groups— customer group scope.Conditions— matching conditions.
Restriction actions
hide:
- the method will be hidden,
- the customer will not see it,
- good for obvious limitations, e.g. parcel locker for oversized items.
error:
- the method will be shown as unavailable,
- the customer will see a message,
- good when it is worth explaining the reason for unavailability.
Priority and Stop Processing
Rules are checked by priority. Higher priority means earlier checking.
Stop Processing = Yes means that after this restriction matches, the module does not check further restrictions for this method.
Recommendation:
- use higher priorities for more specific rules,
- use lower priorities for general rules,
- enable
Stop Processingif the rule should definitively determine method availability.
Managing Extra Fee
When should you use Extra Fee?
Extra Fee is used to add additional charges to an order.
Examples:
- fee for custom packaging,
- surcharge for oversized transport,
- fee for fragile products,
- logistics fee for a specific delivery method,
- surcharge for selected regions.
Creating Extra Fee
Go to:
Sales / Shipping Methods & Rules / Extra FeesThen select Add New or edit an existing fee.
Typical fields:
Is Active— whether the fee is active.Name— internal name.Label— the fee name visible in totals.Target Carrier— the carrier the fee applies to.Target Method— the method the fee applies to.Price Type— price type.Price— fee amount.Apply Mode— charging method.Tax Class ID— tax class if tax mode is used.Priority— priority.Stop Processing— whether to stop further fee charging.Store Views— store view scope.Customer Groups— customer group scope.Conditions— conditions for charging.
Price modes
fixed:
- fixed amount,
- e.g. PLN 19 for packaging.
percent_subtotal:
- percentage of cart value,
- e.g. 3% of order value.
Apply modes
cart:
- one fee for the entire cart.
per_item:
- fee multiplied by product quantity.
per_matching_item:
- fee charged only for products that meet the conditions.
Example:
If the fee for special protection is PLN 5 and the cart contains 3 products that meet the condition, per_matching_item mode will charge PLN 15.
Extra Fee tax
By default, tax on Extra Fee is not calculated:
kowal_shippingrules/fees/tax_mode = noneTo calculate tax:
- Set
Fee Tax ModetoCalculate by Fee Tax Class. - Fill in
Tax Class IDon the Extra Fee rule. - Test cart, order, invoice, and creditmemo.
Extra Fee tax should always be checked against the tax configuration of the specific store.
Managing conditions
The module uses a condition builder similar to Magento rules.
Conditions can apply to, among other things:
- product attributes,
- SKU,
- categories,
- product type,
- weight,
- price,
- cart value,
- product quantity,
- delivery country,
- region,
- city,
- ZIP code,
- coupon,
- selected shipping method.
Example condition for an oversized product
Assumption:
- the product has the
shipping_typeattribute, - the value for oversized shipping is
pallet.
Rule:
Jeżeli produkt w koszyku ma shipping_type = palletPossible actions:
- show the
Dostawa paletowamethod, - hide parcel locker,
- add the
Transport gabarytowyfee.
Recommendations for working with conditions
- create a simple rule first and test it in the cart,
- avoid too many conditions in a single rule,
- describe rules with clear names,
- use unambiguous product attributes for important rules,
- after changing product attributes, test the cart again.
Diagnostics and logging
Dedicated log file:
var/log/kowal_shipping_rules.logDebug can be enabled in:
Stores / Configuration / Sales / Shipping Methods & Rules / General DiagnosticsEnable:
Enable Debug Logging = YesRecommendations:
- do not leave debug logging permanently enabled in production,
- enable debug only for the duration of diagnostics,
- disable debug after testing is complete,
- analyze logs together with the test cart and rule configuration.
Emergency functions
If a problem occurs after implementation, you can independently disable:
The entire carrier
Stores / Configuration / Sales / Delivery Methods / Shipping Methods & Rules / Enabled = NoEffect:
- methods from the
kowal_shippingrulescarrier will not be available.
Only restrictions
Stores / Configuration / Sales / Shipping Methods & Rules / Restrictions / Enable Restrictions = NoEffect:
- methods will not be hidden or blocked by restrictions.
Only Extra Fee
Stores / Configuration / Sales / Shipping Methods & Rules / Extra Fees / Enable Extra Fees = NoEffect:
- additional fees will not be charged.
Migration from Amasty
Migration goal
Migration from Amasty is intended to help transfer restriction and extra fee configuration to Kowal_ShippingRules.
The Kowal module does not require Amasty for normal operation. Amasty can be used as a source of migration data and a reference point during testing.
Supported data sources
The migrator analyzes:
amasty_shiprestriction_ruleamasty_extrafeeamasty_extrafee_optionTarget tables:
kowal_shipping_restrictionkowal_shipping_feeMigration safety rules
The migration has been designed cautiously:
- the report is read-only,
- dry-run does not save data,
- apply works as preview by default,
- saving requires the explicit
--executeoption, - only records with
readystatus are saved, manual_reviewandunsupportedrecords are skipped,- migration is idempotent thanks to the
migration_sourceandmigration_source_keyfields, - migration does not disable Amasty,
- migration does not switch traffic automatically.
Step 1 — baseline report
Run:
bin/magento kowal:shippingrules:amasty:reportThe report will be saved to:
var/report/kowal_shippingrules_amasty_report.jsonThe report shows the presence and count of Amasty tables and Kowal tables.
Step 2 — transformation dry-run
Run:
bin/magento kowal:shippingrules:amasty:report --dry-run --limit=100Dry-run prepares a transformation plan but does not save anything.
Record statuses:
ready— the record can be transferred automatically,manual_review— the record requires manual analysis,unsupported— the record is not supported by the automatic migrator.
If the report contains many manual_review or unsupported records, analyze those rules before apply.
Step 3 — preview apply
Run:
bin/magento kowal:shippingrules:amasty:apply --limit=100This still does not save data. The command shows how many records would be created, skipped, or ended with an error.
Step 4 — apply restrictions
After accepting the preview:
bin/magento kowal:shippingrules:amasty:apply --type=restrictions --limit=100 --executeThe command will save only restrictions with ready status.
Step 5 — apply Extra Fee
After accepting the preview:
bin/magento kowal:shippingrules:amasty:apply --type=fees --limit=100 --executeThe command will save only extra fees with ready status.
Step 6 — post-migration diagnostics
Run:
bin/magento kowal:shippingrules:stabilization:checkAlso check the panel:
Sales / Shipping Methods & Rules / Shipping RestrictionsSales / Shipping Methods & Rules / Extra FeesStep 7 — comparison tests with Amasty
Before disabling or replacing the Amasty configuration, compare results for test carts.
Recommended carts:
- standard product,
- oversized product,
- fragile product,
- several products with different conditions,
- order with different delivery countries,
- order with different ZIP codes,
- order with a coupon,
- order with a selected method covered by Extra Fee.
For each cart, check:
- available shipping methods,
- hidden methods,
- error messages,
- charged extra fee,
- gross/net amounts if tax fee is used,
- order,
- invoice,
- creditmemo.
Step 8 — switching decision
Only after the results are accepted should you plan the production configuration switch.
Recommendations:
- do not disable Amasty without a backup,
- do not delete Amasty data immediately after migration,
- first disable operation on the configuration side,
- keep the possibility of rollback,
- prepare a list of rules that require manual correction.
Rollback after migration
If a problem occurs:
- Disable the
Kowal ShippingRulescarrier. - Disable
Enable Restrictions. - Disable
Enable Extra Fees. - Restore the previous Amasty configuration.
- Check checkout.
- Keep migration reports for analysis.
Post-implementation checklist
Technical
module:statusshowsKowal_ShippingRulesas enabled,setup:upgradecompleted without errors,setup:di:compilecompleted without errors,cache:flushcompleted,stabilization:checkreturns no errors,- the admin panel shows the
Shipping Methods & Rulesmenu, - the log file is written when debug is enabled.
Configuration
- the carrier is enabled,
- at least one shipping method has been created,
- the active method has an active rate,
- store views are set correctly,
- customer groups are set correctly,
- restrictions are enabled or intentionally disabled,
- extra fees are enabled or intentionally disabled,
- tax mode is consistent with the store's tax configuration.
Checkout
- the method appears for a cart that meets the conditions,
- the method does not appear when there is no matching rate,
- the
hiderestriction hides the method, - the
errorrestriction shows a message, - extra fee appears in totals after selecting the method,
- changing the shipping method recalculates the fee,
- order contains fee amounts,
- invoice contains fee amounts,
- creditmemo correctly refunds the fee.
Common issues
Method does not appear in checkout
Check:
- whether the carrier is enabled,
- whether the method is active,
- whether the method has an active rate,
- whether the rate matches the country, region, ZIP code, weight, and subtotal,
- whether the store view is correct,
- whether the customer group is correct,
- whether the method conditions are met,
- whether a restriction is not hiding the method.
Extra Fee is not charged
Check:
- whether
Enable Extra Fees = Yes, - whether the fee is active,
- whether target carrier and target method are correct,
- whether the fee conditions are met,
- whether a shipping method has been selected,
- whether the fee price is greater than zero,
- whether
Stop Processingof an earlier rule has not stopped further charging.
Restriction does not work
Check:
- whether
Enable Restrictions = Yes, - whether the restriction is active,
- whether target carrier and target method are correct,
- whether the restriction conditions are met,
- whether the rule priority is correct,
- whether another rule with
Stop Processingdoes not end processing earlier.
Extra Fee tax is not calculated
Check:
- whether
Fee Tax Mode = Calculate by Fee Tax Class, - whether the fee rule has
Tax Class IDset, - whether the Magento tax configuration returns a tax rate for the address,
- whether the cart has a delivery address,
- whether the fee is actually charged.
Best practices
- Configure simple rules first, then add more conditions.
- Prepare a test cart for each important rule.
- Use clear names for methods, restrictions, and fees.
- Avoid several very similar rules with the same priority.
- Document the reason for creating a restriction or fee in its name.
- After changing product attributes, run a checkout test.
- Enable debug logging only for the duration of diagnostics.
- Perform migration from Amasty in stages: report, dry-run, preview, execute, QA.
Related documents
README.md— technical module description for developers.docs/WDROZENIE.md— detailed implementation documentation and architecture.docs/OPIS_MARKETINGOWY.md— marketing description of the module.