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:
- The
template - The
template - The
template - When accessing
checkout.customer - When accessing
- When accessing
order.customer
Outside of the above contexts, if the customer isn't logged into their account, the customer object returns nil.
Properties
Returns
trueif the customer accepts marketing. Returnsfalseif not.All of the addresses associated with the customer.
TipUse the paginate tag to choose how many addresses to show at once, up to a limit of 20.
Returns
trueif the customer is a B2B customer. Returnsfalseif not.To learn about B2B in themes, refer to Support B2B customers in your theme.
- company_
available_ locations array of company_location 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.
TipUse the paginate tag to choose how many company locations to show at once, up to a limit of 100.
The number of company locations associated with the customer.
The company that the customer is purchasing for.
To learn about B2B in themes, refer to Support B2B customers in your theme.
- current_
location The currently selected company location.
To learn about B2B in themes, refer to Support B2B customers in your theme.
Returns
trueif the email associated with the customer is tied to a customer account. Returnsfalseif 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
isfalseat checkout.During the checkout process, if the customer has an account with the store and enters an email associated with an account, then
istrue. The email is associated with the account regardless of whether the customer has logged into their account.Returns
trueif an avatar is associated with a customer. Returnsfalseif not.A customer may have an avatar associated with their account, which can be displayed in the storefront.
TipUse with the
avatarfilter to render the customer's avatar.All of the orders placed by the customer.
TipUse the paginate tag to choose how many orders to show at once, up to a limit of 20.
- payment_
methods array of customer_payment_method 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.
- 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
nilwill be returned.The tags associated with the customer.
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.
TipUse money filters to output a formatted amount.
Example
{
"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"
}Check whether the customer object is defined
customer object is definedWhen 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.
Code
{% if customer %}
Hello, {{ customer.first_name }}!
{% endif %}Data
{
"customer": {
"first_name": "Cornelius"
}
}