Overview
Container Deposits brings container deposits into Craft Commerce. It was built around Ireland's Re-turn Deposit Return Scheme, but it works just as well for any DRS or container deposit programme.
What it does
- An admin keeps 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 goes onto product/variant field layouts, and merchandisers pick the right deposit for each SKU.
- When a shopper adds a product to their cart, the matching deposit shows up as a separate line item, with its own quantity tied to the parent product.
- Deposit line items are non-promotable (catalog pricing rules skip them) and sit under 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 since it's 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.
End result: one deposit line item per deposit type, always in step with the cart, no front-end JS needed.