Difference between revisions of "Cart.liquid"

From Spiffy Stores Knowledge Base

(New page: This template is used to render the shopping [Liquid Template Variables - cart|cart]] page. This is where the customer can review all the items purchased before proceeding to checkout. ...)
(No difference)

Revision as of 18:18, 16 September 2008

This template is used to render the shopping [Liquid Template Variables - cart|cart]] page.

This is where the customer can review all the items purchased before proceeding to checkout.

You should always include a condition to check whether the shopping cart is empty or not.

For example:

{% if cart.item_count == 0 %}

To the list all the items in a cart, use the following code:

<ul>
{% for item in cart.items %}
  <li>{{ item.quantity }} x {{ item.title }}</li>
{% endfor %}
</ul>

This example would create a list of all items in the cart including the quantity of each item.

In addition, a cart should include the price of each item, and the total amount of all the purchases.

Variables

In cart.liquid you have access to the following variables:

  • cart - The current cart.
  • handle - The handle of the cart.

In addition, all global variables are available.