The customer object
customer object contains information about a customer who has a customer account.
Where and when is it defined
customer object is global in the sense that you can access it in all layout, template and snippet files. However, the object is only defined when a customer is logged-in. You can verify if a customer is logged-in with this code:
If one is able to view a store page that lives under
/accounts then one is logged-in, therefore you don't need to check if
customer is defined in the templates /customers/account.liquid, /customers/order.liquid and /customers/addresses.liquid before you access the variable's attributes.
true if the customer accepts marketing, returns
false if the customer does not.
Returns an array of all addresses associated with a customer. See customer_address for a full list of available attributes.
Returns the number of addresses associated with a customer.
Returns the default customer_address.
Returns the email address of the customer.
Returns the first name of the customer.
true if the email associated with the customer is tied to a customer account. Returns
false if it is 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
false when accessed in email templates and at checkout.
During the checkout process, if the customer has an account with the store and enters an email associated with their account, then
true. The email is associated to the account regardless of whether the customer has logged into their account.
Returns the id of the customer.
Returns the last name of the customer.
Returns the last order placed by the customer, not including test orders.
Returns the full name of the customer.
Returns an array of all orders placed by the customer.
Returns the total number of orders a customer has placed.
Returns the phone number of the customer.
Returns the list of tags associated with the customer.
Returns whether or not the customer is exempt from taxes.
Returns the total amount spent on all orders.