Cart

The cart variable represents the user’s cart. This variable is available on the following pages:

  • cart
  • index
  • product

total_items

Total number of items in the cart.

<p>You have {{ cart.total_items }} in your cart.</p>

This is equivalent to using the length filter on the items variable:

<p>You have {{ cart.items|length }} in your cart.</p>

items

Line items in the cart. Each line item is an instance of a LineItem.

coupons

Coupons currently active in the cart. Each coupon is an instance of a Coupon.

Note

only one coupon is allowed at a time. It is an array to allow for future expansion.

total_discount

Total discount applied to the cart. To get a discount for a coupon, loop over the coupons list.

<p>You have saved: {{ cart.total_discount|money }}!</p>

total_price

Total price of all the items in the cart. This includes any discounts applied.

<p>Total: {{cart.total_price|money}}</p>