shoppy.customer.update(input)
Updates the current customer’s profile information.
Parameters
| Param | Type | Required | Description |
|---|
input | CustomerUpdateInput | Yes | Fields to update |
| Field | Type | Description |
|---|
firstName | string | First name |
lastName | string | Last name |
phone | string | Phone number |
acceptsMarketing | boolean | Marketing email opt-in |
Returns
Promise<ShopifyCustomer> - The updated customer object.
Throws
Error - If not logged in or update fails.
Examples
Update name
const customer = await shoppy.customer.update({
firstName: 'John',
lastName: 'Doe'
})
console.log(`Updated: ${customer.displayName}`)
document.querySelector('#profile-form').addEventListener('submit', async (e) => {
e.preventDefault()
const formData = new FormData(e.target)
try {
await shoppy.customer.update({
firstName: formData.get('firstName'),
lastName: formData.get('lastName'),
phone: formData.get('phone'),
acceptsMarketing: formData.get('newsletter') === 'on'
})
showSuccess('Profile updated!')
} catch (error) {
showError(error.message)
}
})
Toggle marketing preference
async function toggleNewsletter(optIn) {
await shoppy.customer.update({
acceptsMarketing: optIn
})
showToast(optIn ? 'Subscribed to newsletter' : 'Unsubscribed')
}
Updates trigger all subscribers, so your UI will automatically reflect changes.