customers/login

The customers/login template renders the customer login page, which hosts the form for logging into a customer account.

An example of the customer login template in Dawn

Location

The customers/login template is located in the templates > customers directory of the theme:

Content

You should include the customer login form in your customers/login template or a section inside of the template.

Optionally, you can include "Forgot your password" and guest checkout options.

The customer login form

The customer login form can be added with the Liquid form tag and accompanying 'customer_login' parameter. Within the form tag block, you need to include the following:

Input type name
Email email customer[email]
Password password customer[password]

For example:

Usage

When working with the customers/account template, you should familiarize yourself with the following:

When linking to the login page, you need to consider the store's customer accounts settings, as well as the current login status.

For example, you don't need to show any links if customer accounts aren't enabled. If the customer is already logged in, then you can link to the account page instead. If customer accounts are enabled and optional, and the customer isn't logged in, then you can show a link to the register page:

Provide a “Forgot your password" option

You can add a password recovery form with the Liquid form tag and accompanying 'recover_customer_password' parameter. Within the form tag block, you need to include an <input> with the following attributes:

  • type="email"
  • name="email"

For example:

If the password recovery form is submitted successfully, then the customer will receive an email with instructions on how to reset their password.

Offer guest checkout

If customer accounts are optional or required, then customers can log in to their account at the first step of checkout:

When customer accounts are optional, you can allow customers to check out as a guest, instead of logging in to an account. You can do this with the Liquid form tag and accompanying 'guest_login' parameter. Within the form tag block, you need to include a submit input. Additionally, to ensure that the form only shows when coming directly from the checkout, you can use the shop.checkout.guest_login attribute of the shop object.

For example:

Redirect customers on login

By default, when a customer logs in, they're directed to the customer account page. You can change this by using the return_to parameter of the Liquid form tag.

For example, the following directs customers to the all-products collection page:

On this page