-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Describe the bug
usageLimit and perCustomerUsageLimit are ignored for promotions that do not have a couponCode.
Auto-applied promotions (without a coupon code) can be used an unlimited number of times, even when usage limits are configured in the Admin UI. Usage limits are only enforced when a coupon code is explicitly applied via applyCouponCode().
This results in inconsistent behavior between coupon-based promotions and auto-applied promotions.
To Reproduce
Steps to reproduce the behavior:
- Go to Admin UI → Promotions
- Create a new promotion without a coupon code
- Set:
usageLimit = 1perCustomerUsageLimit = 1
- Add a condition so the promotion auto-applies (e.g., minimum order value)
- Place multiple eligible orders
- Observe that the promotion continues to apply beyond the configured limits
Expected behavior
Promotions should respect usageLimit and perCustomerUsageLimit regardless of whether a couponCode is configured.
Alternatively, if usage limits are intentionally meant to apply only to coupon-based promotions, this should either:
- Be clearly documented, or
- Be prevented at the Admin UI level for non-coupon promotions.
Actual behavior
Usage limits are only enforced inside PromotionService.validateCouponCode(), which is called exclusively when applying a coupon via OrderService.applyCouponCode().
Auto-applied promotions follow this flow:
OrderService.applyPriceAdjustments()
→ OrderCalculator.applyPromotions()
→ Promotion.test()
→ Promotion.apply()
Promotion.test() checks:
- start/end dates
- coupon presence (if defined)
- promotion conditions
However, it does not check usageLimit or perCustomerUsageLimit.
As a result, auto-applied promotions never enforce usage limits.
- @vendure/core version: 3.5.3
- Database: PostgreSQL
- Operating System: macOS
- Package manager: yarn