Allow customers to create an account at checkout
Depending on your checkout flow you might not be asking customers to create an account during the checkout process. This can be a good idea if you're worried about checkout drop-outs and want to minimise the amount of time it takes to checkout.
If so, you might still want to encourage your visitors to create an account with you, but directly on the checkout page (with minimal fuss).
In the example above, the customer just needs to tick to say that they want to create an account and then enter a password.
If they do so, once the checkout form is submitted (even if payment isn't complete) an account will be created for them.
Adding the code
You'll need two addition fields on your checkout_address.twig page in a suitable position.
<input type="checkbox" name="create_new_customer">
The above will display a tick box that must be ticked by the customer if they want to create an account.
<input type="password" name="new_customer_password">
The above will display a password field that also must be completed.
These fields will need to be styled so that they appear nicely and in keeping with the rest of your website's design.
You could use jQuery to show/hide the password field depending on whether the tick box has been ticked.
Customers that are already logged in
You should hide the fields described above if the customer is already logged into an account using the variable global.customer.id which will return true if the customer is logged into either a customer or trade account.
{% if not global.customer.id %} <p><label>Tick here to create an account for faster checkout</label><input type="checkbox" name="create_new_customer"></p> <p><label>Enter your password</label><input type="password" name="new_customer_password"></p> {% endif %}