Skip to main content

customers/register

The customers/register template renders the customer register page, which hosts the form for customer account creation.

Tip

Refer to the customers/register template and its main section in Dawn for an example implementation.

An example of the customer register template in Dawn

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

└── theme
├── layout
├── templates
| └── customers
| ├── register.json
| ...
...

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

Tip

If you're using a JSON template, then any HTML or Liquid code needs to be included in a section that's referenced by the template.

Anchor to The customer register formThe customer register form

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

Inputtypename
First nametextcustomer[first_name]
Last nametextcustomer[last_name]
Emailemailcustomer[email]
Passwordpasswordcustomer[password]

For example:

{% form 'create_customer' %}
{{ form.errors | default_errors }}

<div className="first-name">
<label htmlFor="first-name">First name</label>
<input type="text" name="customer[first_name]" />
</div>

<div className="last-name">
<label htmlFor="last-name">Last name</label>
<input type="text" name="customer[last_name]" />
</div>

<div className="email">
<label htmlFor="email">Email</label>
<input type="email" name="customer[email]" />
</div>

<div className="password">
<label htmlFor="password">Password</label>
<input type="password" name="customer[password]" />
</div>

<div className="submit">
<input type="submit" value="Create" />
</div>
{% endform %}

When working with the customers/register template, you should familiarize yourself with redirecting customers on account creation.

Anchor to Redirect customers on account creationRedirect customers on account creation

By default, when a customer creates an account, they're directed to the home page. However, you can specify a page to direct customers to using the return_to parameter of the Liquid form tag.

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

{% form 'create_customer', return_to: routes.all_products_collection_url %}
<!-- form content -->
{% endform %}

Was this page helpful?