How to add / edit Phone number for a customer account through Customer Account API

How to add / edit Phone number for a customer account through Customer Account API

ike188
Shopify Partner
3 0 0

There is no way to add a phone number during customer account creation and through customerUpdate mutation, and the SmsMarketingState of the phone number

Reply 1 (1)

Huptech-Web
Shopify Partner
909 186 190

@ike188 

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.

 

If you found this response helpful, please do like and accept the solution. Thanks!
Need support with Customizing your Shopify store?
Feel free to contact me at info@huptechweb.com or Visit our website Huptech Web.
Instant Shortcode Builder: Integrate customizable UI features anywhere in your store - No coding knowledge required