QUANTM7 Docs

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

Properties

PropertyTypeDescription
customer.idstringThe unique customer ID
customer.emailstringTheir email address
customer.first_namestringFirst name
customer.last_namestringLast name
customer.namestringFull name (first and last combined)
customer.phonestringPhone number, if set

Orders

PropertyTypeDescription
customer.ordersarrayPast orders, newest first
customer.orders_countnumberTotal number of orders
customer.total_spentnumberLifetime 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>

Order history

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

Addresses

PropertyTypeDescription
customer.addressesarrayAll saved addresses
customer.default_addressaddressThe default shipping address

Each address has these fields:

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

Tags

PropertyTypeDescription
customer.tagsarrayTags 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 %}

Metafields

PropertyTypeDescription
customer.metafieldsobjectCustom data fields for this customer
{% if customer.metafields.custom.loyalty_tier %}
  <p>Loyalty tier: {{ customer.metafields.custom.loyalty_tier }}</p>
{% endif %}

On this page