Skip to content

Pool System

The plugin includes an automatic protection system against applying multiple discounts to the same item. This system is called the Cart Pool.

  1. Initialization — At the beginning, a “pool” of all cart items is created with no discounts applied
  2. Processing by priority — Discounts are processed according to priority (lower number = processed first)
  3. Pool consumption — After a discount is applied, the item is removed from the pool
  4. Next discount validation — Subsequent discounts only see the remaining items

The pool system is primarily used for:

  • BOGO discounts (Buy X Get X, Buy X Get Y)
  • Free Gift discounts
  • Cart discounts

For BOGO discounts, trigger products are also removed from the pool.

Pool at start: 10 units of product A

PhasePoolAppliedRemaining
Start10 units
Discount 1 (priority 0)10 units3 units trigger + 1 unit discount6 units
Discount 2 (priority 10)6 units2 units trigger + 1 unit discount3 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

Priority determines access to the full pool. Lower priority values are processed first and have access to the complete inventory.

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.

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

To visualize the pool state, use the debug panel.