activate_customer_password_form
Generate an account activation form with the required field password. token is required to activate the account, clicking on the bounce from the activation email will carry the token parameter in the url.
Form Input
customer[password] string required
Password.
Maximum length: 18
Minimum length: 6
customer[accepts_marketing] boolean
Whether the customer subscribe to marketing emails.
{{#activate_customer_password_form}}
form_content
{{/activate_customer_password_form}}
form_content
The form contents.
Example
Activate customer
{{#activate_customer_password_form id="customer-activate-form"}}
<div class="password">
<label for="customer[password]">user password</label>
<input type="password" name="customer[password]" placeholder="user password" />
</div>
<div class="accepts-marketing">
<input type="checkbox" name="customer[accepts_marketing]" value="true">
<label for="accepts-marketing">Subscribe to email marketing</label>
</div>
<div class="submit">
<input class="submit-button" type="submit" value="Submit">
</div>
{{/activate_customer_password_form}}
<script>
class Activate {
constructor() {
this.form = document.querySelector('#customer-activate-form');
this.form.addEventListener('submit', this.onSubmitHandler.bind(this));
this.activate = new window.Shopline.customerAccount.Activate(this.form)
}
onSubmitHandler(e) {
e.preventDefault();
this.activate.submit()
.then(response => {
window.location.href = '/user/signIn';
})
.catch(error => {
// Handling failure
console.log(error)
})
}
}
// Initializing the JS SDK
window.Shopline.loadFeatures(
[
{
name: 'customer-account-api',
version: '0.3'
}
],
function(error) {
if (error) {
throw error;
}
new Activate();
}
);
</script>
Was this article helpful to you?