Variant Price Surcharge
Variant Price Surcharge for Sylius 2: price variants as a percentage and fixed surcharge on a base variant's price, overridable per channel, effective in storefront, cart and Shop API.
Variant Price Surcharge
This documentation always refers to the latest released version.
Overview
Sylius stores the price of every variant as a fixed amount per channel. A variant that costs "50 percent more than the standard variant" cannot be expressed that way, and Sylius has no parent variant that carries a reference price. This plugin fills the gap: you mark one variant per product as base variant and give every other variant a percentage and/or a fixed surcharge. If a channel needs different values, you override them for that channel.
The price is derived from the base variant's price on every price calculation. When its price changes, all variants with a surcharge follow automatically.
Formula: price = (base price + fixed surcharge) x (percentage / 100). A percentage of 100 leaves the price unchanged, 150 means 50 percent more.
graph LR
A["Storefront (Twig)"] --> C["Price calculator (decorator)"]
B["Shop API"] --> C
D["Cart recalculation"] --> C
C --> E{"Surcharge for the variant?"}
E -->|No| F["Variant's own price"]
E -->|Yes| G["Base variant price with formula, values per channel"]
Documentation
| Page | Content |
|---|---|
| Installation and Operation | Composer (Packeton), bundle, routes, setup command, update, uninstall |
| Configuration | Variant form, per-channel overrides, formula with examples, global switch, overview |
| Storefront and Cart | Where the surcharge takes effect, original price, what stays unchanged |
| Shop API and Headless | Affected fields, behaviour with missing prices |
| Extending | Decorated price calculators, repository, Twig hook, routes |
| Troubleshooting and FAQ | Common problems, known limitations, frequent questions |
| Technical Details | Flow, data model, plugin structure |
Features
| Feature | Description |
|---|---|
| Surcharge relative to a base variant | One variant per product provides the reference price, every other variant gets a percentage and/or fixed surcharge |
| Override per channel | Surcharge enabled, percentage and fixed surcharge can each be overridden per channel, fields you do not override take the global value |
| Follows the channel price | The base price comes from the base variant per channel, including its catalog promotions |
| Dual-mode | Storefront, cart and Shop API return the same price because the plugin decorates the central Sylius price calculators (from Sylius 2.3 also the catalog price calculator) |
| Maintained in the variant form | A dedicated "Price surcharge" section when editing a variant, no separate CRUD area |
| Overview | List of all configured surcharges with a link to the variant |
| Global switch | Turns off all surcharges instantly and keeps the configuration |
| Setup command | mmd:variant-price-surcharge:setup runs only this plugin's migrations and checks the route import |
No change to ProductVariant |
Own tables with a foreign key, no class override needed in your project |
Requirements
| Requirement | Version | Notes |
|---|---|---|
| Sylius | ^2.2 | Package sylius/sylius, tested with 2.2 and 2.3 |
| PHP | ^8.3 | |
| Database | MySQL or MariaDB | The bundled migrations are written in MySQL syntax |
Composer package: mmd/sylius-variant-price-surcharge-plugin, distributed through the Packeton registry (https://packeton.markus-michalski.net). The steps are on the Installation and Operation page.
License
Commercial license: one Sylius installation (all channels plus its development and staging environments) per license, no redistribution, updates for 12 months from purchase.
Support
For questions or bugs, contact me at support@markus-michalski.net.