Cart
The cart
object represents the current shopping cart in the store. It provides access to cart items, totals, discounts, shipping, and payment information.
Usage Example
{%- comment -%} Show cart summary and list items {%- endcomment -%}
<p>You have {{ cart.item_count }} items in your cart.</p>
<ul>
{% for item in cart.items %}
<li>
<strong>{{ item.product.title }}</strong> × {{ item.quantity }}<br>
Price: {{ item.line_price | money }}
</li>
{% endfor %}
</ul>
<p>Subtotal: {{ cart.subtotal | money }}</p>
<p>Shipping: {{ cart.shipping_price | money }}</p>
<p>Total: <strong>{{ cart.total | money_with_currency }}</strong></p>
{% if cart.applicable_for_free_shipping %}
<p>Congratulations! Your order qualifies for free shipping.</p>
{% elsif cart.calc_free_shipping_limit %}
<div class="free-shipping-info">
<strong>{{ cart.calc_free_shipping_limit.title }}</strong><br>
<span>{{ cart.calc_free_shipping_limit.description }}</span><br>
<span>Add {{ cart.calc_free_shipping_limit.amount_to_limit | money }} more (limit: {{ cart.calc_free_shipping_limit.limit_amount | money }}) for free shipping.</span>
</div>
{% endif %}
Properties
applicable_for_free_shipping
Returns true if the current cart is applicable for free shipping.
calc_free_shipping_limit
Returns information about the free shipping limit if available, otherwise returns false. When available, this object contains:
title
: The title for the free shipping offer (e.g. “Free shipping!”).description
: A description of the free shipping offer (e.g. “Spend a bit more to get free shipping”).limit_amount
: The minimum cart total required for free shipping.amount_to_limit
: The remaining amount needed to reach the free shipping threshold.
Example usage:
{% if cart.calc_free_shipping_limit %}
<div>
<strong>{{ cart.calc_free_shipping_limit.title }}</strong><br>
<span>{{ cart.calc_free_shipping_limit.description }}</span><br>
<span>Add {{ cart.calc_free_shipping_limit.amount_to_limit | money }} more (limit: {{ cart.calc_free_shipping_limit.limit_amount | money }}) for free shipping.</span>
</div>
{% endif %}
currency
Returns the currency for this cart.
delivery_time_in_days
Returns the estimated delivery time in days.
discounts
Lists applied discounts for this cart.
expires
If there is a reservation time applied to this cart, returns the timestamp when the reservation expires.
id
Returns the id of the cart.
item_count
Returns the total amount of items in the cart.
items
Lists added items to this cart.
payment_fee
Returns the total payment fees for this cart.
payment_methods
Lists selected payment methods for this cart.
shipping_methods
Lists selected shipping methods for this cart.
shipping_price
Returns the total shipping costs for this cart.
subtotal
Returns the subtotal for this cart.
tax
Returns the total tax included.
tax_free
Returns the tax free price.
total
Returns the total of the cart.
weight_in_grams
Returns the total cart weight in grams.