cart.liquid

The cart.liquid template provides an overview of the items in the visitor's cart.

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 ›

icon-accounticon-add-newicon-add-storeicon-appicon-appleicon-archiveicon-arrowdownicon-ascicon-bookicon-cancelicon-cart-addonicon-checkouticon-cherryicon-collectionicon-comfirmicon-confirmicon-couponicon-creditsicon-currencyicon-dashboardicon-discounticon-disintegrateicon-domainicon-dscicon-duplicateicon-editicon-emailicon-exclamation-triangleicon-exporticon-eyeicon-eye-slashicon-fullscreenicon-fullscreen-closeicon-generalicon-gifticon-gridicon-hddicon-helpicon-importicon-infoicon-integrationicon-invoiceicon-likeicon-listicon-locationicon-logouticon-new-tabicon-not-secureicon-optionicon-ordericon-outline-arrowdownicon-pageicon-paymenticon-plusicon-posicon-pricingicon-printericon-producticon-product-sumicon-product-sum-xicon-redirecticon-reporticon-reseticon-searchicon-secureicon-settingicon-shippingicon-staricon-storeicon-switch-storeicon-tagicon-taxesicon-templateicon-themeicon-tickicon-trashicon-unarchiveicon-uploadicon-user-tagicon-usersicon-weighticon-wholesale