Introduction
Container Deposits adds container deposits to Craft Commerce. It was built around Ireland's Re-turn Deposit Return Scheme, but works equally well for any DRS or container deposit programme.
What it does
- An admin maintains a list of deposit types in the Craft control panel (e.g. Small Container - €0.15, Large Container - €0.25).
- A Container Deposit Type field is added to product/variant field layouts; merchandisers pick the applicable deposit on each SKU.
- When a shopper adds a product to their cart, the matching deposit appears as a separate line item with its own quantity tied to the parent product.
- Deposit line items are non-promotable (excluded from catalog pricing rules) and use a dedicated VAT-exempt tax category.
How it works under the hood
Each deposit type is backed by a DepositPurchasable element - a real Craft Commerce purchasable with a price, SKU, and snapshot, but invisible to shoppers because it is never linked to a product page.
A listener on Order::EVENT_BEFORE_SAVE reconciles the order's line items every time the cart changes:
- Walk the non-deposit line items and look up the assigned deposit type on each purchasable's field layout.
- Sum the expected deposit quantities, grouped by deposit type.
- Update existing deposit line items in place, add new ones for new types, and remove orphans.
The result: a single deposit line item per deposit type, always in sync with the cart, no front-end JS required.