Cart liquid object

Published

{{ cart }} object is a global object that can be reached from all context, however items needs to be placed in the cart to contain information.

To inspect the object use the print_r filter, {{ cart | print_r }}

Properties of the cart can be reached with {{ cart.property }}.

Property Description
shopId Id for the shop/site
id Cart id
sessionId Visitor session id
gatewayId Gateway id
shippingId Shipping id
email Customer email address
lang Session language setting
currency Session currency setting
country Customer country setting
items An array of the items in the cart
itemsAmount Currency, subtotal, VAT and total of the items
paymentProvider Chosen payment provider
requiresShipping Cart requires shipping
quantity Number of items in the cart
addresses Array of the customer addresses
shippings Array of the possible shippings for the cart
providers Array of payment providers
createdAt Cart creation date
totalAmount Cart total amount
itemsCount Number of type of items in cart
shipping Selected shipping
totalTax Total tax of the whole cart
Properties in the cart object

Items amount

{{ cart.itemsAmount }}

Property Description
currency Cart item currency
sub Cart item total without tax
vat Cart item vat
total Cart item total
Item cost properties in the cart object

Items

Items in the cart, {{ cart.items }}

Property Description
id Item id
productId Product id
variantId Product variant id
vendorId Product vendor id
handle Product handle
title Product title
type Product type
sku Stock keeping unit of the product
image Featured product image
quantity Amount of the item in the cart
price Product price
amount Total cost of the items in the cart
taxRate Product tax rate
weight Product weight
tags Product tags
shippable If product requires shipping
netPrice Product price without tax
netAmount Total item cost without tax
Item in cart object

Addresses

An array of all addresses, such as shipping, billing, phone and VAT number, to the customer is found under {{ cart.addresses }}.

Note that addresses are also gathered on the checkout form object and are more adapted to be used in the checkout form.

Property Description
id Address id
type Type of address
title Address title
active Active status on the address
validFrom Address valid from date
validTo Address valid to date
info Contains the address information
entity
entityId

Shipping

The selected shipping is found under {{ cart.shipping }} and an array with all shippings with {{ cart.shippings }}.

Property Description
id Shipping id
title Shipping title
serviceName Shipping service name
carrierName Shipping carrier name
duration contains unit (hours,days,months), min and max values
duration.unit Shipping unit (hours,days,months)
duration.min Min amount of time for delivery
duration.max Max amount of time for delivery
cost Contains properties for shipping costs
cost.currency Shipping cost currency
cost.delivery Delivery cost
cost.handling Handling cost
cost.deliveryTax Tax on delivery fee
cost.handlingTax Tax on handling fee
cost.sub Shipping cost without tax
cost.total Total shipping cost
cost.totalTax Total tax on shipping
cost.deliveryTaxRate Specified tax rate on delivery fee
cost.handlingTaxRate Specified tax rate on handlng fee
cost.taxRate Calculated tax rate on shipping
public Specifies if it is a public rate
Shipping properties in cart object
{% for shipping in cart.shippings %}
	<li class="w-full flex items-center justify-between ps-3 gap-4">
			<input 
				id="{{shipping.id}}" 
				type="radio" 
				value="{{shipping.id}}" 
				name="shipping" 
				class="radio radio-sm" 
				{% if shipping.id == form.shippingId %}checked{% endif %}
			>
			<label 
				for="{{shipping.id}}" 
				class="flex flex-col items-start grow text-sm-content/60"
			>
					<span class="text-strong">{{ shipping.carrierName }}</span>
					<span class="text-xs">{{ 'delivery in' | t }} {{shipping.duration.min}} - {{shipping.duration.max}} {{shipping.duration.unit}} {{ '(weekdays)' | t }}</span>
			</label>
			<p class="mr-2 text-strong">{{shipping.cost.total | money }}</p>
	</li>
{% endfor %}
Example of using the cart.shippings property to list shipping options

Payment providers

An array with all payment providers is specified in {{ cart.providers }} and the chosen payment provider in {{ cart.paymentProvider }}

Property Description
gatewayId Payment gateway id
title Payment title as specified in admin
provider Gateway type
description Payment description (Manual payments only)
instruction Payment instruction (Manual payments only)
Properties for a payment gateway
{% for provider in cart.providers %}
	<input 
		class="btn transition delay-150" 
		type="radio" 
		name="gateway" 
		value="{{provider.gatewayId}}" 
		aria-label="{{provider.title}}" 
	/>
{% endfor %}
Using cart.providers to list all providers