customers/login template renders the customer login page, which hosts the form for logging into a customer account.
customers/login template is located in the
customers directory of the theme:
You should include the customer login form in your
customers/login template or a section inside of the template.
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:
When working with the
customers/account template, you should familiarize yourself with the following:
- Linking to the login page
- Providing a "Forgot your password" option
- Offering guest checkout
- Redirecting customers on login
Link to the login page
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:
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.
Redirect customers on login
For example, the following directs customers to the all-products collection page: