Customer The customer object for logged-in visitor details, orders, and addresses.
The customer object holds data about the logged-in visitor. When no one is logged in, customer is nil. Always check for this before using its properties.
{% if customer %}
< p >Welcome back, {{ customer .first_name }}!</ p >
{% else %}
< a href = "/account/login" >Log in</ a >
{% endif %}
Property Type Description customer.idstring The unique customer ID customer.emailstring Their email address customer.first_namestring First name customer.last_namestring Last name customer.namestring Full name (first and last combined) customer.phonestring Phone number, if set
Property Type Description customer.ordersarray Past orders, newest first customer.orders_countnumber Total number of orders customer.total_spentnumber Lifetime spend in the smallest currency unit
< p >You have placed {{ customer .orders_count }} {{ customer .orders_count | pluralize: 'order' , 'orders' }}.</ p >
< p >Total spent: {{ customer .total_spent | money }}</ p >
{% for order in customer .orders %}
< div class = "order-row" >
< span >{{ order .name }}</ span >
< span >{{ order .created_at | date: '%d %B %Y' }}</ span >
< span >{{ order .total_price | money }}</ span >
</ div >
{% endfor %}
Property Type Description customer.addressesarray All saved addresses customer.default_addressaddress The default shipping address
Each address has these fields:
Property Description address.first_nameFirst name address.last_nameLast name address.address1Street line 1 address.address2Street line 2 address.cityCity address.provinceCounty or state address.zipPostcode or ZIP code address.countryCountry name address.phonePhone number
{% if customer .default_address %}
< p >
{{ customer .default_address.address1 }}< br />
{{ customer .default_address.city }},
{{ customer .default_address.zip }}< br />
{{ customer .default_address.country }}
</ p >
{% endif %}
Property Type Description customer.tagsarray Tags assigned to this customer in the admin
Tags are useful for showing content to specific groups of customers:
{% if customer .tags contains 'wholesale' %}
< p >Your trade discount has been applied.</ p >
{% endif %}
Property Type Description customer.metafieldsobject Custom data fields for this customer
{% if customer .metafields.custom.loyalty_tier %}
< p >Loyalty tier: {{ customer .metafields.custom.loyalty_tier }}</ p >
{% endif %}