Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
There is no way to add a phone number during customer account creation and through customerUpdate mutation, and the SmsMarketingState of the phone number
You can add a Phone number during customer account creation by using the below GraphqlMutation
mutation MyMutation {
customerCreate(
input: {email: "Valid email", password: "test@123", phone: "valid number with country code", lastName: "lasname", firstName: "firstName", acceptsMarketing: true / false}
) {
customer {
acceptsMarketing
createdAt
displayName
email
firstName
id
lastName
numberOfOrders
phone
tags
updatedAt
}
customerUserErrors {
message
field
code
}
userErrors {
field
message
}
}
}
Here, the output of the above mutation
{
"data": {
"customerCreate": {
"customer": {
"acceptsMarketing": true,
"createdAt": "2024-05-16T11:12:32Z",
"displayName": "firstName lasname",
"email": "mayank@huptechweb.com",
"firstName": "firstName",
"id": "gid://shopify/Customer/7618199322782",
"lastName": "lasname",
"numberOfOrders": "0",
"phone": "+91xxxxxxxxx",
"tags": [],
"updatedAt": "2024-05-16T11:12:33Z"
},
"customerUserErrors": [],
"userErrors": []
}
}
}
If you encounter any challenges, please feel free to let me know. I would be happy to assist you.
If the solution presented meets your needs and addresses your query effectively, I encourage you to accept it as the chosen answer. This will acknowledge the support you received and aid fellow community members in identifying reliable and effective solutions for their similar concerns.
Thank you.