- Getting Started
- Liquid reference
- Filters reference
- Tags reference
- Localization
- Theme structure
- Theme sections
- Theme assets
- Theme config
- Theme layout
- Theme templates
-
- article.liquid
- blog.liquid
- cart.liquid
- collection.liquid
- customer/account.liquid
- customer/addresses.liquid
- customer/details.liquid
- customer/login.liquid
- customer/order.liquid
- customer/register.liquid
- customer/reset-password.liquid
- home.liquid
- page.no-heading.liquid
- products.liquid
- search.liquid
- list-collections.liquid
- store-locator.liquid
- 404.liquid
- customer/activate_account.liquid
- customer/orders.liquid
- Submission
cart.liquid
The cart.liquid template provides an overview of the items in the visitor's cart.
The cart form
The cart is submitted through an HTML <form> with the attributes action="/cart" and method="post". Include the CSRF token as a hidden input. A button named update saves quantity changes, and a button named checkout sends the visitor to checkout.
<form action="/cart" method="post">
<input type="hidden" name="_token" value="{% csrf %}">
/* Loop through the cart line items */
<button type="submit" name="update">{{ 'cart.general.update' | t }}</button>
<button type="submit" name="checkout" value="true">{{ 'cart.general.checkout' | t }}</button>
</form>
cart.items
Returns an array of the line items in the cart. Loop through it to render each item's image, title, quantity and price. Every item is a line_item object. More info ›
{% for item in cart.items %}
<a href="{{ item.url }}">
<img src="{{ item.image_url }}" alt="{{ item.title | escape }}">
{{ item.name }}
</a>
<input type="number" name="updates[]" value="{{ item.quantity }}" min="0">
{{ item.final_line_price | money: cart.currency }}
{% endfor %}
cart.total_price
Returns the total price of all the items in the cart. Use one of the money filters to return the value in a monetary format. The related cart.item_count returns the number of items and can be used to detect an empty cart.
{{ cart.total_price | money: cart.currency }}
The cart object exposes more attributes, such as the currency and note. More info ›