Skip to content

Cart Behaviour

Where deposits appear

Deposit line items appear alongside their parent products in:

  • The cart page
  • The checkout review
  • Order confirmation emails
  • The CP order detail view

They are stored as ordinary LineItem records with their options array marked { "_deposit": true, "_depositTypeId": <id> }.

Line Item

Twig templates can identify them with:

twig
{% for item in cart.lineItems %}
  {% if item.options._deposit ?? false %}
    <tr class="deposit">…</tr>
  {% else %}
    <tr>…</tr>
  {% endif %}
{% endfor %}

Synchronisation rules

The sync runs on Order::EVENT_BEFORE_SAVE for any cart that has not been completed:

Cart eventEffect on deposit line items
Product with deposit addedNew deposit line item created (or qty incremented on an existing one).
Qty of a deposit-bearing product changedMatching deposit line item qty updated to reflect the new total.
Deposit-bearing product removedDeposit line item removed when no parent items remain for that type.
Deposit field removed from a productSame as removal - deposit drops out on next save.
Order completedAll further sync is skipped; deposits are preserved as-is on the completed order.

Properties of deposit line items

PropertyValue
purchasableA DepositPurchasable element
descriptionThe deposit type's name
skudeposit-<handle>
priceThe deposit type's amount
qtySum of the qty of every parent line item sharing the deposit type
taxCategoryIdcontainerDeposit category - no VAT
shippingCategoryIdFree shipping (deposit doesn't add shipping cost)
options._deposittrue
options._depositTypeIdThe deposit type ID

Performance

The sync logic only calls Order::setLineItems() when a deposit was actually added, removed, or had its quantity changed. Idle saves are no-ops, so there's no recalculation cost for carts that already match expected state.