shoppy.customer.register(input)
Creates a new customer account in Shopify. On success, automatically logs in the customer and returns their data.
Parameters
| Param | Type | Required | Description |
|---|
input | CustomerRegisterInput | Yes | Registration details |
| Field | Type | Required | Description |
|---|
email | string | Yes | Customer’s email |
password | string | Yes | Account password |
firstName | string | No | First name |
lastName | string | No | Last name |
phone | string | No | Phone number |
acceptsMarketing | boolean | No | Marketing opt-in |
Returns
Promise<ShopifyCustomer> - The newly created and authenticated customer.
Throws
Error - If registration fails (e.g., email already exists).
Examples
Basic registration
try {
const customer = await shoppy.customer.register({
email: '[email protected]',
password: 'securePassword123'
})
console.log(`Account created for ${customer.email}`)
} catch (error) {
console.error(error.message) // "Email has already been taken"
}
document.querySelector('#register-form').addEventListener('submit', async (e) => {
e.preventDefault()
const formData = new FormData(e.target)
try {
const customer = await shoppy.customer.register({
email: formData.get('email'),
password: formData.get('password'),
firstName: formData.get('firstName'),
lastName: formData.get('lastName'),
phone: formData.get('phone'),
acceptsMarketing: formData.get('marketing') === 'on'
})
// Customer is now logged in
window.location.href = '/welcome'
} catch (error) {
showError(error.message)
}
})
After successful registration, the customer is automatically logged in. No need to call .login() separately.