Syntax
Description
TheupdateProfile method updates customer profile information in both Shopify and Lantern. This is an asynchronous operation that validates and saves the provided customer data.
Parameters
fields (Object)
An object containing the customer fields to update. All fields are optional.
| Property | Type | Description |
|---|---|---|
firstName | string | The customer’s first name |
lastName | string | The customer’s last name |
phone | string | The customer’s phone number in E.164 format (e.g., "+12125552368") |
birthDate | string | The customer’s birth date in ISO-8601 format (e.g., "1990-01-01") |
acceptsMarketing | boolean | Whether the customer accepts email marketing communications |
options (Object)
An object containing additional options for the update operation. All fields are optional.
| Property | Type | Default | Description |
|---|---|---|---|
refetchData | boolean | false | Whether to refetch and update the customer data from the server after the update |
Return Value
Type:Promise<Object>
The method returns a Promise that resolves to an object with the following structure:
| Property | Type | Required | Description |
|---|---|---|---|
success | boolean | ✓ | Whether the update operation was successful |
errors | Record<string, string> | Object with field names as keys and error messages as values |
Error Object Structure
Theerrors object uses field names as keys and error messages as values:
Examples
Basic Usage
Complete Profile Update with Refetching
Form Integration
Error Handling
The method can fail in two ways:-
Validation Errors: When field values don’t meet requirements (e.g., invalid phone format)
- The Promise resolves with
success: falseand anerrorsobject - The errors object maps field names to their respective error messages
- The Promise resolves with
-
Network/System Errors: When the request cannot be completed
- The Promise is rejected with an error object
- Handle these with try/catch blocks