Variant Price Surcharge: Troubleshooting and FAQ
Troubleshooting Variant Price Surcharge for Sylius: price does not change, errors after an update, setup command aborts, missing channel pricing, known limitations and FAQ.
Variant Price Surcharge: Troubleshooting and FAQ
The price does not change
Symptom: A variant with a percentage and surcharge still shows its own price.
Check:
- Is Enable price surcharges switched on on the Price surcharge settings page?
- Is Apply surcharge enabled on the variant, and is the variant itself not marked as Base variant? Also check the Per-channel overrides section: if the affected channel is set to "No, for this channel" there, the channel gets no surcharge.
- Does another variant of the same product have Base variant set? Without a base variant every price stays unchanged.
- Is the percentage 100 and the fixed surcharge 0? Then the result is the base variant's price, not the variant's own price.
- Is there a row for the variant in the overview of surcharges? A row is only created when Base variant or Apply surcharge was enabled on save, or a channel carries its own setting.
- Is there a log entry at level
errorwith the text "Could not resolve variant price surcharge"? Then an error occurred while resolving the surcharge, for example because the migrations are missing. In that case the plugin returns the variant's own price. Runbin/console mmd:variant-price-surcharge:setup.
After an update, variants show their own price or the variant form reports an error
Symptom: After composer update, variants with a surcharge show their own price, and editing a variant in the admin throws an error.
Solution: The table mmd_product_variant_price_surcharge_channel does not exist yet. Run bin/console mmd:variant-price-surcharge:setup and clear the cache.
The setup command aborts
| Message | Cause and solution |
|---|---|
| "Migrations this plugin builds on are still open." | Sylius migrations are still open. Run bin/console doctrine:migrations:migrate, then run the setup command again |
| "The migrations of this plugin are not registered with Doctrine." | The bundle is not enabled, or sylius_core.prepend_doctrine_migrations is set to false. Check config/bundles.php and that setting |
| "The migrations ran, but Doctrine does not list them as executed." | The migrations ran but do not appear in doctrine_migration_versions. Check the database connection and the migrations table |
If the command reports that the route is not imported and prints a YAML snippet, add it as described on Installation and Operation. The command carries on in that case.
The "Price surcharge" section is missing in the variant form
Check: Is the bundle registered in config/bundles.php and the cache cleared? The plugin registers its Twig hooks itself as soon as the bundle is loaded.
The menu entry is missing or the page throws an error
Check: Is the route import @MmdSyliusVariantPriceSurchargePlugin/config/routes/admin.yaml present? The menu entry points to the route mmd_variant_price_surcharge_admin_settings.
Error about missing channel configuration
Symptom: A product page or the cart reports that there is no price for the variant and channel.
Solution: Store a price in the affected channel for both the surcharge variant and the base variant. The plugin looks up both and deliberately does not catch this error.
The fixed surcharge of a channel has the wrong currency
The Fixed surcharge field in the global section uses the base currency of the first channel, or USD in a shop without any channel. The stored value is an amount in the smallest unit that applies unchanged in every channel without its own setting, whatever that channel's currency. A stored 100 therefore becomes 1.00 of each channel's currency, not a converted amount. For an exact amount in a specific currency, override the fixed surcharge in that channel, where you enter it in the channel's base currency.
Known limitations
- Exactly one base variant per product is intended, but the plugin does not enforce it. The base variant applies to the whole product and cannot be overridden per channel.
- The global switch cannot be overridden per channel.
- The fixed surcharge input multiplies the amount by 100 to get the stored unit, so it suits currencies with two decimal places.
- The Apply surcharge column in the overview shows the global value only. A variant that gets a surcharge only through a per-channel override appears there as "No".
- The lowest price before discount (
lowestPriceBeforeDiscount) is not recalculated. - Sorting by price in product lists uses the stored channel prices.
- Surcharges cannot be maintained through an import or an API.
- The migrations only run on MySQL and MariaDB.
FAQ
Does the surcharge follow when I change the base variant? Yes. The price is derived from the base variant's current price on every calculation, nothing is cached.
Can a variant with a surcharge be the base for a third one? No. The base is always the variant marked as base variant, and its price never gets a surcharge.
What happens when I delete the base variant? Its surcharge row is deleted with it. The product then has no base variant, and the other variants keep their own prices.
Can I model a discount instead of a markup? Yes, with a percentage below 100.
Can a price become negative? No, the result is rounded to whole cents and is at least 0.
What applies in a channel I have not configured? The variant's global values.
Does the plugin process personal data or call external services? No.