setono / sylius-coupon-url-application-plugin
Apply Sylius promotion coupons via a URL query string or a dedicated /coupon page.
Package info
github.com/Setono/SyliusCouponUrlApplicationPlugin
Type:sylius-plugin
pkg:composer/setono/sylius-coupon-url-application-plugin
Fund package maintenance!
Requires
- php: >=8.2
- doctrine/persistence: ^3.0 || ^4.0
- setono/doctrine-orm-trait: ^1.2
- sylius/core: ^2.0
- sylius/core-bundle: ^2.0
- sylius/order: ^2.0
- sylius/promotion: ^2.0
- symfony/config: ^6.4 || ^7.4
- symfony/dependency-injection: ^6.4 || ^7.4
- symfony/event-dispatcher: ^6.4 || ^7.4
- symfony/form: ^6.4 || ^7.4
- symfony/http-foundation: ^6.4 || ^7.4
- symfony/http-kernel: ^6.4 || ^7.4
- twig/twig: ^3.0
- webmozart/assert: ^1.11
Requires (Dev)
- api-platform/symfony: ^4.3.3
- lexik/jwt-authentication-bundle: ^3.1
- payum/core: ^1.7.5
- setono/sylius-plugin: ^2.1
- sylius/sylius: ~2.2.5
- symfony/debug-bundle: ^6.4 || ^7.4
- symfony/dotenv: ^6.4 || ^7.4
- symfony/intl: ^6.4 || ^7.4
- symfony/web-profiler-bundle: ^6.4 || ^7.4
- symfony/webpack-encore-bundle: ^2.2
This package is auto-updated.
Last update: 2026-05-18 06:54:35 UTC
README
Apply coupons by going to example.com/coupon or directly from the URL by going to
example.com/?coupon=CODE.
Installation
composer require setono/sylius-coupon-url-application-plugin
Import routing
# config/routes/setono_sylius_coupon_url_application.yaml setono_sylius_coupon_url_application: resource: "@SetonoSyliusCouponUrlApplicationPlugin/config/routes.yaml"
or if your app doesn't use locales:
# config/routes/setono_sylius_coupon_url_application.yaml setono_sylius_coupon_url_application: resource: "@SetonoSyliusCouponUrlApplicationPlugin/config/routes_no_locale.yaml"
Install assets
php bin/console assets:install
How coupon application works
The plugin's main use case is sending coupon links from email campaigns,
newsletters, ads, etc. A customer clicks https://example.com/?coupon=CHRISTMAS
and the coupon is attached to their cart immediately — even before they
have added a single item. As soon as the cart matches the promotion's rules
(e.g. a minimum cart total, a required taxon), the discount activates.
To support this flow, the plugin runs the coupon application in two stages:
-
Coupon-level eligibility (
PromotionCouponEligibilityCheckerInterface) — gates whether the coupon is attached at all. This checks the coupon's start/end dates, total usage limit, per-customer usage limit, and channel applicability. If any of these fail, the coupon is rejected with an error flash and not attached to the cart. -
Promotion-level eligibility (
PromotionEligibilityCheckerInterface) — determines which flash the customer sees after the coupon is attached. This includes the underlying promotion's rules (cart-total threshold, taxon/product allow-lists, etc.):- Cart already qualifies → success flash
setono_sylius_coupon_url_application.coupon_applied("The coupon code is now activated in your cart") - Cart doesn't qualify yet → info flash
setono_sylius_coupon_url_application.coupon_applied_not_fulfilled("The coupon code is saved in your cart, but the discount is not active yet because your cart does not contain the items, amounts or meet other criteria that the coupon requires…")
- Cart already qualifies → success flash
This deliberately differs from Sylius's built-in cart coupon widget, which rejects coupons up-front when the cart doesn't satisfy promotion rules. The plugin's leniency is the point — customers should be able to click the link in an email before shopping, not after.