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 nameattribute with the following syntax:

attributes[attribute-name]

Shown below is a basic example of how to use an HTML input of type "text" to capture information on the cart page.

<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

For more examples on how to use cart attributes, see Ask a customer for additional information.

cart.currency

This attribute is part of selling in multiple currencies, which is currently in beta for Shopify Plus plans.

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 }}

Output

USD

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.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">{{ cart.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. The amount is in the customer's local (presentment) currency.

cart.total_discount

Returns the total of all discounts (the amount saved) for the cart. The amount is in the customer's local (presentment) currency.

cart.total_price

Returns the total price of all of the items in the cart after discounts have been applied. This amount is in the customer's local (presentment) currency.

cart.total_weight

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

Ready to start selling with Shopify?

Try it free