Skip to main content
shoppy.customer.update(input)
Updates the current customer’s profile information.

Parameters

ParamTypeRequiredDescription
inputCustomerUpdateInputYesFields to update

CustomerUpdateInput

FieldTypeDescription
firstNamestringFirst name
lastNamestringLast name
phonestringPhone number
acceptsMarketingbooleanMarketing 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}`)

Profile form handler

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.