Pool System
The plugin includes an automatic protection system against applying multiple discounts to the same item. This system is called the Cart Pool.
How It Works
Section titled “How It Works”- Initialization — At the beginning, a “pool” of all cart items is created with no discounts applied
- Processing by priority — Discounts are processed according to priority (lower number = processed first)
- Pool consumption — After a discount is applied, the item is removed from the pool
- Next discount validation — Subsequent discounts only see the remaining items
Applicable Discount Types
Section titled “Applicable Discount Types”The pool system is primarily used for:
- BOGO discounts (Buy X Get X, Buy X Get Y)
- Free Gift discounts
- Cart discounts
BOGO — Special Behavior
Section titled “BOGO — Special Behavior”For BOGO discounts, trigger products are also removed from the pool.
Practical Example: “Buy 3 Get 1 Free”
Section titled “Practical Example: “Buy 3 Get 1 Free””Pool at start: 10 units of product A
| Phase | Pool | Applied | Remaining |
|---|---|---|---|
| Start | 10 units | — | — |
| Discount 1 (priority 0) | 10 units | 3 units trigger + 1 unit discount | 6 units |
| Discount 2 (priority 10) | 6 units | 2 units trigger + 1 unit discount | 3 units |
Discount 1 (priority 0): Buy 3 Get 1
- Applied to 3 units (triggers) + 1 unit (discount)
- Removed from pool: 4 units total
- Pool after application: 6 units
Discount 2 (priority 10): Buy 2 Get 1
- Validated against remaining 6 units only
- Applied to 2 units + 1 unit
- Removed from pool: 3 units
- Pool after application: 3 units
Importance of Priorities
Section titled “Importance of Priorities”Priority determines access to the full pool. Lower priority values are processed first and have access to the complete inventory.
Scenario with Two Rules
Section titled “Scenario with Two Rules”With 5 units of product A:
- Rule A: Buy 2 Get 1 (50% discount), priority 0
- Rule B: Buy 3 Get 1 (100% discount), priority 10
Result: Rule A is applied to 3 units, 2 units remain. Rule B needs 3 units, so it is not applied.
Practical Tip
Section titled “Practical Tip”Set better/higher discounts with a lower priority so they are applied first:
- “Buy 2 Get 1 FREE (100% discount)” — priority 0
- “Buy 3 Get 1 at half price (50% discount)” — priority 10
Debugging the Pool System
Section titled “Debugging the Pool System”To visualize the pool state, use the debug panel.