跳到主要内容

customers/login

customers/login template 渲染客户登录页面,包含登录客户账户的表单。

位置

customers/login template 位于 theme 的 templates > customers 目录下:

└── theme
├── layout
├── templates
| └── customers
| ├── login.liquid
| ...
...

内容

您应该在 customers/login template 或其内部的 section 中包含客户登录表单

您还可以添加"忘记密码"和访客结账选项。

客户登录表单

客户登录表单可以使用 form 添加。

输入项typename
Emailtextemail
Passwordpasswordpassword

例如:

<form method="POST" action="{{ '/api/customers/sign_in' | add_root_url }}">
<div>
<label for="email">Email</label>
<input id="email" name="email" />
</div>
<div>
<label for="password">Password</label>
<input id="password" type="password" name="password" />
</div>
<button type="submit" data-track="dj.login">Login</button>
</form>

使用说明

使用 customers/login template 时,您应该熟悉以下内容:

链接到登录页面

如果客户未登录,您可以链接到登录页面。如果客户已登录,则可以链接到订单页面

{% if customer.id %}
<a href="{{ routes.account_order_url }}">My orders</a>
{% else %}
<a href="{{ routes.account_login_url }}">Login</a>
{% endif %}