customer
The customer currently accessing the store. When the customer has logged into their account, the customer object can be accessed globally.It's also defined in the following context:
- The template customers/account
- The template customers/addresses
- The template customers/order
- Access object checkout.customer
- Access object gift_card.customer
- Access object order.customer
In addition to the above scenario, if the customer is not logged into their account, the customer object returns null.
Check if the customer object exists
When using the customer object in a template or object where its existence is not certain, it is advisable to first check if the customer object exists.
{{#if customer }}
Hello, {{ customer.first_name }}!
{{/if}}
Properties
Whether the customer has subscribed to marketing emails.
Whether the customer has subscribed to marketing SMS.
All personal shipping addresses of the customer.
Return all personal shipping addresses of the customer, the customer address can only add up to 50 items.
The number of personal shipping addresses for the customer. The range is from 0 to 50.
If the customer is a B2B customer, return true; otherwise, return false.
To learn about B2B functionality, please refer to the B2B Company.
The list of company addresses accessible to the customer.
To learn about B2B functionality, please refer to the B2B Company.
The company information used by the customer when placing an order.
To learn about B2B functionality, please refer to the B2B Company.
The company location used by the customer when placing an order.
To learn about B2B functionality, please refer to the B2B Company.
Returns true if customer has applied to delete the account. Returns false if not.
The time at which the customer account will be deleted.
The default personal shipping address of the customer.
The customer's email address. Returns null when empty.
The customer's first name.
The customer's last name.
Third-party account information of the customer.
Returns true if the email associated with the customer is bound to a customer account; otherwise, returns false.
Customers can check out without creating an account in the store. If the customer does not have a store account, customer.has_account is false at checkout.
During checkout, if the customer has a store account and enters the email associated with the account, customer.has_account is true. The email is associated with the account regardless of whether the customer is logged into it.
The customer's ID.
The customer's full name.
All orders of the customer.
Default display the latest 10 records, can adjust the page size through the paginate helper.
The total number of orders for the customer.
The customer's phone number. Returns null when empty.
The customer's mobile area code.
The customer's tags.
Returns true if tax-exempt, otherwise returns false.
The total expenditure amount of all current orders for the customer. Can be formatted using the money helper.
Deprecated Properties
Whether the customer accepts marketing.
Deprecated because the name didn't make it clear that the customer has subscribed to marketing emails or SMS.
Has been replaced by customer.accepts_email_marketing and customer.accepts_sms_marketing.
Object Example
{
"accepts_marketing": true,
"accepts_email_marketing": false,
"accepts_sms_marketing": false,
"addresses": [],
"addresses_count": 0,
"b2b": false,
"cancelling_account": true,
"cancelling_time": "2024-12-31",
"company_available_locations": [],
"current_company": {},
"current_location": null,
"default_address": {},
"email": "cornelius.potionmaker@gmail.com",
"first_name": "Cornelius",
"has_account": true,
"id": 5625411010625,
"last_name": "Potionmaker",
"last_order": {},
"login_sources": [{
"login_source": "google",
"nickname": "your name"
}, {
"login_source": "facebook",
"nickname": "your name"
}],
"name": "Cornelius Potionmaker",
"orders": [],
"orders_count": 0,
"phone": "+441314960905",
"phone_dialing_code": "44",
"tags": [
"newsletter"
],
"tax_exempt": false,
"total_spent": "56.00",
}