Skip to content

customer object ​

Last updated View as Markdown

The logged in customer. It is available in every template, and it is nil when no customer is logged in.

Properties ​


NameTypeDescription
idstringThe customer id
emailstringThe email
phonestringThe phone number, or nil
first_namestringThe first name, or nil
last_namestringThe last name, or nil
namestringThe first and last name
accepts_marketingbooleanWhether the customer accepts marketing emails
tagsarray of stringThe tags the seller added to the customer
has_accountbooleanWhether the customer has an account
orders_countnumberThe number of orders
total_spentstringThe total of all orders, in the store currency
ordersarray of order objectThe orders, newest first, 50 at a time. Use paginate for more
last_orderorder object or nullThe most recent order
addressesarray of address objectThe saved addresses, the default address first
addresses_countnumberThe number of saved addresses
default_addressaddress object or nullThe default address, or the first address when none is the default
new_addressaddress objectAn empty address for the form that adds an address
liquid
{% if customer %}
  <a href="{{ routes.account_url }}">{{ customer.first_name }}</a>
  <a href="{{ routes.account_logout_url }}">Log out</a>
{% else %}
  <a href="{{ routes.account_login_url }}">Log in</a>
{% endif %}

Orders ​

{% paginate customer.orders by 10 %} paginates the orders. order.customer_url is the URL of the order page.

liquid
{% paginate customer.orders by 10 %}
  {% for order in customer.orders %}
    <a href="{{ order.customer_url }}">{{ order.name }}</a>
    <span>{{ order.financial_status }}</span>
    <span>{{ order.total | money }}</span>
  {% endfor %}
{% endpaginate %}