Logged-In Customer Session
customer is nil for anonymous visitors. When logged in, it exposes profile data from the customer account. Use {% if customer %} to gate account-specific UI — never rely on hidden form fields for authentication.
Conditional account navigation
{% if customer %}
<div class="account-nav">
<p>Welcome back, {{ customer.first_name }}!</p>
<a href="{{ routes.account_url }}">Account</a>
<a href="{{ routes.account_logout_url }}">Log out</a>
</div>
{% else %}
<a href="{{ routes.account_login_url }}">Log in</a>
<a href="{{ routes.account_register_url }}">Create account</a>
{% endif %}- customer.email, customer.first_name, customer.last_name
- customer.orders — order history (account pages only)
- customer.addresses — saved shipping addresses
- customer.tags — segments for B2B or loyalty programs
- customer.accepts_marketing — email consent flag
Tip: For 'Reorder' buttons, loop customer.orders on the account page — each order has order.line_items with product references.