The cart object

The cart object has the following attributes:

cart.attributes

cart.attributes allow the capturing of more information on the cart page. This is done by giving an input a name attribute with the following syntax:

attributes[attribute-name]

You can add a double underscore (__) prefix to an attribute name to make it private. Private attributes behave like other cart attributes except that they can't be read from Liquid or the Ajax API. You can use them for data that doesn't affect the page rendering, which allows for more effective page cacheing.

Shown below is a basic example of how to use an HTML input of type "text" to capture information on the cart page. You can also create a cart.attributes input by using the Shopify UI elements generator.

<label>What is your Pet's name?</label>
<input type="text" name="attributes[your-pet-name]" value="{{ cart.attributes.your-pet-name }}" />

cart.attributes can be accessed in order email templates, the order status page of the checkout, as well as in apps such as Order Printer.

Input

{{ attributes.your-pet-name }}

Output

Haku

cart.cart_level_discount_applications

Returns an array of any cart-specific discount applications for the cart.

Input

{% for discount_application in cart.cart_level_discount_applications %}
  Discount name: {{ discount_application.title }}
  Savings: -{{ discount_application.total_allocated_amount | money }}
{% endfor %}

Output

Discount name: SUMMER16
Savings: -$20.00

cart.currency

Returns the currency of the cart. If your store uses multi-currency, then the cart.currency is the same as the customer's local (presentment) currency. Otherwise, the cart currency is the same as your store currency.

To return the list of currencies that are accepted by your store, see the shop.enabled_currencies object.

Input

{{ cart.currency.iso_code }}

Output

USD

cart.discount_applications

Returns an array of discount applications for the cart.

Input

{% for discount_application in cart.discount_applications %}
  Discount name: {{ discount_application.title }}
  Savings: -{{ discount_application.total_allocated_amount | money }}
{% endfor %}

Output

Discount name: SUMMER16
Savings: -$20.00

cart.item_count

Returns the number of items inside the cart.

Input

{{ cart.item_count }} {{ cart.item_count | pluralize: 'item', 'items' }} ({{ cart.total_price | money }})

Output

25 items ($53.00)

cart.items

Returns all of the line items in the cart.

cart.items_subtotal_price

Returns the sum of the cart's line-item prices after any line-item discount. The subtotal doesn't include taxes (unless taxes are included in the prices), cart discounts, or shipping costs.

cart.note

cart.note allows the capturing of more information on the cart page.

This is done by submitting the cart form with an HTML textarea and wrapping the cart.note output.

<label>Gift note:</label>
<textarea name="note"></textarea>

cart.note can be accessed in order email templates, the order status page of the checkout, as well as in apps such as Order Printer. For examples on how to use cart notes, see Ask a customer for additional information.

Input

{{ note }}

Output

Hope you like the gift, Kylea!

cart.original_total_price

Returns the subtotal of the cart before any discounts have been applied.

cart.total_discount

Returns the total of all discounts (the amount saved) for the cart.

cart.total_price

Returns the total price of all of the items in the cart after discounts have been applied.

cart.total_weight

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