Variant Price Surcharge: Storefront and Cart
Where the variant price surcharge takes effect in the Sylius storefront: product page, product cards, cart, original price, price range filter, and what deliberately stays unchanged.
Variant Price Surcharge: Storefront and Cart
The plugin does not change any storefront templates and ships neither storefront routes nor JavaScript of its own. It replaces the Sylius price calculators with decorators. Every place in the storefront that gets prices from these calculators therefore shows the price with the surcharge automatically. You do not need to adapt a theme.
| Sylius version | Decorated calculators |
|---|---|
| 2.2 | sylius.calculator.product_variant_price |
| 2.3 and later | sylius.calculator.product_variant_price and additionally sylius.calculator.product_variant_catalog_price, which was added in 2.3 and supplies the prices for the product page, listings, variant selection and API |
The plugin detects on its own whether the catalog calculator exists. You do not need to configure anything.
Where the surcharge takes effect
| Place | Behaviour |
|---|---|
| Product page | Price and original price of the selected variant, as well as the price overview of the variants |
| Product cards | Price of the variant the card shows |
| Cart and checkout | The unit price of each item is set from the calculator whenever the cart is recalculated, so it includes the surcharge |
| Promotion price range filter | The check uses the same calculator |
The surcharge depends on the channel of the request. If the channel has its own setting, it applies, otherwise the global one (see Configuration).
Original price and catalog promotions
- The original price (strikethrough price) is calculated with the same formula from the base variant's original price. If the base variant has a catalog promotion, price and original price of the surcharge variant are both derived from it.
- A catalog promotion that applies directly to the surcharge variant does not influence its price, because the price comes from the base variant.
- The lowest price before the discount is not changed: it comes unchanged from the variant's own data and may therefore not match the calculated price.
What stays unchanged
- Sorting by price in product lists: Sylius sorts in the database by the variants' stored channel prices, not by the calculated price.
- Stored channel prices: They remain in the database and in the variant form, but are not used for the selling price of a variant with a surcharge.
- Existing orders: Items that Sylius no longer recalculates keep their price.
Requirements per channel
- The variant with the surcharge also needs its own stored price in every channel, because Sylius looks it up first. It is discarded afterwards.
- The base variant needs a price in every channel. If it is missing, pricing the surcharge variant in that channel raises the Sylius error for missing channel pricing. The plugin deliberately does not catch it so that no wrong price is shown.
Shop API behaviour is described on Shop API and Headless.