Liquid Template Variables - cart: Difference between revisions

From Spiffy Stores Knowledge Base
Jump to: navigation, search
Admin (talk | contribs)
Admin (talk | contribs)
Line 34: Line 34:


== <code>cart.total_weight</code> ==
== <code>cart.total_weight</code> ==
Returns the total weight of all items in the shopping cart.
Weight is always returned as grams. Use weight or weight_with_unit filter to display the actual weight in your preferred unit system.
<pre>The total of your cart is: {{ cart.total_weight | weight_with_unit }}</pre>


== <code>cart.note</code> ==
== <code>cart.note</code> ==


== <code>cart.attributes</code> ==
== <code>cart.attributes</code> ==

Revision as of 19:17, 11 September 2008

The liquid template variable cart has the following attributes:

cart.item_count

Returns the number of items currently in the shopping cart.

For example:

{% if cart.item_count == 0 %}
  Your shopping cart is empty!
{% else %}
  You have <a href="/cart">{{ cart.item_count }} {{ cart.item_count | pluralize: 'item', 'items' }}</a> in your cart
{% endif %} 

cart.items

Returns all the items in the shopping cart. Each item is a Line Item.

For example:

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

cart.total_price

Returns the total price of all items in the shopping cart.

For example:

The total of your cart is: {{ cart.total_price | money }}

cart.total_weight

Returns the total weight of all items in the shopping cart.

Weight is always returned as grams. Use weight or weight_with_unit filter to display the actual weight in your preferred unit system.

The total of your cart is: {{ cart.total_weight | weight_with_unit }}

cart.note

cart.attributes