Skip to main content

customer

A customer of the store.

The customer object is directly accessible globally when a customer is logged in to their account. It's also defined in the following contexts:

Outside of the above contexts, if the customer isn't logged into their account, the customer object returns nil.

Properties

Anchor to
accepts_marketing

Returns true if the customer accepts marketing. Returns false if not.

Anchor to
addresses
array of address

All of the addresses associated with the customer.

Tip

Use the paginate tag to choose how many addresses to show at once, up to a limit of 20.

Anchor to
addresses_count

The number of addresses associated with the customer.

Returns true if the customer is a B2B customer. Returns false if not.

To learn about B2B in themes, refer to Support B2B customers in your theme.

Anchor to
company_available_locations

The company locations that the customer has access to, or can interact with.

To learn about B2B in themes, refer to Support B2B customers in your theme.

Tip

Use the paginate tag to choose how many company locations to show at once, up to a limit of 100.

Anchor to
company_available_locations_count

The number of company locations associated with the customer.

Anchor to
current_company

The company that the customer is purchasing for.

To learn about B2B in themes, refer to Support B2B customers in your theme.

The currently selected company location.

To learn about B2B in themes, refer to Support B2B customers in your theme.

Anchor to
default_address

The default address of the customer.

The email of the customer.

The first name of the customer.

Returns true if the email associated with the customer is tied to a customer account. Returns false if not.

A customer can complete a checkout without making an account with the store. If the customer doesn't have an account with the store, then customer.has_account is false at checkout.

During the checkout process, if the customer has an account with the store and enters an email associated with an account, then customer.has_account is true. The email is associated with the account regardless of whether the customer has logged into their account.

Returns true if an avatar is associated with a customer. Returns false if not.

A customer may have an avatar associated with their account, which can be displayed in the storefront.

Tip

Use with the avatar filter to render the customer's avatar.

The ID of the customer.

The last name of the customer.

Anchor to
last_order

The last order placed by the customer, not including test orders.

The full name of the customer.

Anchor to
orders
array of order

All of the orders placed by the customer.

Tip

Use the paginate tag to choose how many orders to show at once, up to a limit of 20.

Anchor to
orders_count

The total number of orders that the customer has placed.

Anchor to
payment_methods

The customer's saved payment methods.

The phone number of the customer.

This phone number is only populated if the customer checks out using a phone number during checkout, opts in to SMS notifications, or if the merchant has manually entered it.

Anchor to
store_credit_account

The store credit account associated with the customer.

The account shown will be in the currency associated with the customer’s current context. For example, if a customer is browsing the storefront in the US market, their USD store credit account will be returned. If they do not have a USD store credit account nil will be returned.

Anchor to
tags
array of string

The tags associated with the customer.

Returns true if the customer is exempt from taxes. Returns false if not.

Anchor to
total_spent

The total amount that the customer has spent on all orders in the currency's subunit.

The value is output in the customer's local (presentment) currency.

For currencies without subunits, such as JPY and KRW, tenths and hundredths of a unit are appended. For example, 1000 Japanese yen is output as 100000.

Tip

Use money filters to output a formatted amount.

{
"accepts_marketing": true,
"addresses": [],
"addresses_count": 5,
"b2b?": false,
"company_available_locations": [],
"company_available_locations_count": 1,
"current_company": {},
"current_location": null,
"default_address": {},
"email": "cornelius.potionmaker@gmail.com",
"first_name": "Cornelius",
"has_account": true,
"has_avatar?": false,
"id": 5625411010625,
"last_name": "Potionmaker",
"last_order": {},
"name": "Cornelius Potionmaker",
"orders": [],
"orders_count": 1,
"payment_methods": [],
"phone": "+441314960905",
"store_credit_account": {},
"tags": [
"newsletter"
],
"tax_exempt": false,
"total_spent": "56.00"
}
Anchor to Check whether the `customer` object is defined

Check whether the customer object is defined

When using the customer object outside of customer-specific templates or objects that specifically return a customer, you should check whether the customer object is defined.

{% if customer %}
Hello, {{ customer.first_name }}!
{% endif %}

Output

Hello, Cornelius!
Was this section helpful?