Money attributes such as prices and totals are returned in the customer's local (presentment) currency. Use a money filter to show the result as a money amount.
The cart object has the following attributes:
cart.attributes
cart.attributes lets you collect more information on the cart page. Give an input a name attribute with this syntax:
attributes[attribute-name]
Prefix an attribute name with a double underscore (__) to make it private. Private attributes behave like other cart attributes, except that Liquid and the Ajax API cannot read them. Use them for data that does not affect page rendering, which allows more effective page caching.
Here is a simple example that uses an HTML text input to collect 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, on the order status page of the checkout and in apps such as order printers.
{{ attributes.your-pet-name }}
Fluffy
cart.cartleveldiscount_applications
Returns an array of all cart-level discount applications of the cart.
{% for discount_application in cart.cart_level_discount_applications %}
Discount code: {{ discount_application.title }}
Savings: -{{ discount_application.total_allocated_amount | money }}
{% endfor %}
Discount code: SUMMER16
Savings: -€20.00
cart.currency
Returns the currency of the cart. If your shop uses multiple currencies, cart.currency is the customer's local (presentment) currency. Otherwise the cart currency is the currency of your shop.
The currencies your shop accepts are listed in shop.enabled_currencies.
{{ cart.currency.iso_code }}
EUR
cart.discount_applications
Returns an array of discount applications for the cart.
{% for discount_application in cart.discount_applications %}
Discount code: {{ discount_application.title }}
Savings: -{{ discount_application.total_allocated_amount | money }}
{% endfor %}
Discount code: SUMMER16
Savings: -€20.00
cart.item_count
Returns the number of items in the cart.
{{ cart.item_count }} {{ cart.item_count | pluralize: 'item', 'items' }} ({{ cart.total_price | money }})
25 items (€53.00)
cart.items
Returns all line items in the cart.
cart.itemssubtotalprice
Returns the sum of the cart's line item prices after line item discounts. The subtotal does not include taxes (unless taxes are included in the prices), cart discounts or shipping costs.
cart.note
cart.note lets you collect more information on the cart page.
Submit the cart form with an HTML textarea named note:
<label>Gift note:</label>
<textarea name="note"></textarea>
There can only be one {{ cart.note }} field on the cart page. If there are several, the last one in the Document Object Model (DOM) is submitted with the form.
cart.note can be accessed in order email templates, on the order status page of the checkout and in apps such as order printers.
{{ note }}
Hope you like the gift, Jane!
cart.originaltotalprice
Returns the subtotal of the cart before discounts are applied.
cart.taxes_included
Returns true if taxes are included in your product prices, otherwise false.
This is set in the tax settings of your shop. If taxes are included or excluded based on the customer's country, the value reflects the tax requirements of the customer's country.
{% if cart.taxes_included %}
Taxes included
{% else %}
Taxes excluded
{% endif %}
Taxes included
cart.total_discount
Returns the sum of all discounts (the amount saved) for the cart.
cart.total_price
Returns the total price of all items in the cart after discounts.
cart.total_weight
Returns the total weight of all items in the cart.
More properties
VersaCommerce also provides these properties on the cart object:
| Properties | Returns |
|---|---|
product_count, items_with_changed_qty_count, products, recommendations, requires_shipping, empty? |
Quantity totals, changed positions, linked products and cart state |
subtotal_price, subtotal_price_decimal, subtotal_price_cents, items_subtotal_price_decimal, items_subtotal_price_cents, total_price_decimal, total_price_cents, checkout_charge_amount, extra_price, shipping_cost, payment_cost, tax_amount, tax_rate, reduced_tax_rate, coupon_value |
Cart pricing totals and explicit numeric representations |
order_code, coupon, payment, carrier, shipping_type, standard_shipping_types, standard_shipping_items, extra_shipping_items, standard_shipping_items_count, extra_shipping_items_count, standard_shipping_cost, extra_shipping_cost, delivery_countries, destination_country, billable_countries, estimated_delivery, errors, url |
Cart checkout, destination, validation and shipping data |