API or method to update customer EMAIL address

Solved
Highlighted
Shopify Partner
29 4 4

Dear all,

I am new to this shopify environment.

Right now we are working for my new client. I have following clarification.

1. The registered customer(Logged in user) need to update their email address. So that, next time he should login with updated mail address.  Is it possible to do in Shopify env. And if yes, How to achieve this with Shopify API. If possible please show some sample code also appreciable.

 

2. I need to add EMAIL MAGAZINE's SUBSCRIPTION/UNSUBSCRIPTION  as radio button type.  How to do this  using shopify API. Is it possible to do? If yes, please let me know the API if you aware.

 

3. Agree "TERMS & CONDITION" to be added as "checkbox" and to be SAVED while update the account details.

Is there any special API for this? if yes please let me know

 

Thanks in advance.

 

Regards,

Pon maheswaran K

0 Likes
Highlighted
Shopify Partner
29 4 4

Dear all,

Please let me know, why my question has not been answered yet?

Is it  irrelevant to this forum or something else.?

 

Please let me know. If you answer me, then i could correct myself move forward to use/Not use this shopify.

 

 

Thanks & Regards,

Pon maheswaran K

0 Likes
Highlighted
Tourist
4 0 2

Did you end up finding out whether a customer can update their email on the Shopify site?

1 Like
Highlighted
Shopify Partner
29 4 4

This is an accepted solution.

Dear @kamilski81 ,

yes. it can be updated using following API.

https://shopify.dev/docs/admin-api/rest/reference/customers/customer?api[version]=2020-04#update-202...

Procedure as follows.

Goto your Shopify store Admin.

There is a "Apps" option at left side(https://famzon-development.myshopify.com/admin/apps)

Click on "Apps" and it will open the respective things at right side.

 

In right side find "Manage private apps" Hyper link.

On click of that, will open "Private apps" screen in which you can find "Create new private app" button.

Now click on "Create new private app" button and create the new private APP and get API key and password.

And below of "API key" and "Password" field, you can find "ADMIN API PERMISSIONS" heading.

provide "read and Write" permission for "Customers". and save that App.

 

Now copy that "Example URL" provided below that Password field. And append Email update API as follows.( In API_KEY and PASSWORD, replace with your private app's credentials)

https://{API_KEY}:{PASSWORD}@famzon-development.myshopify.com/admin/api/2020-04/customers/"+{{customer.id}}+".json

 

Now using this API, make your AJAX call as follows to update email ID or any other customer information like first name, last name, password etc..

   
var  customerdata = {
          "customer": {
            "id": {{customer.id}} ,
            "first_name": address_first_name,
            "last_name": address_last_name,
            "email": email,
            "password": password,
            "password_confirmation": cust_pswd_confirmation
             }
      };

 

In above JSON data,  "id": {{customer.id}}  is mandatory. Because, the information you are updating based on each user(Customer). So inputting customer ID is mandatory.

jQuery.ajax({
url: "https://API_KEY:PASSWORD@famzon-dev-msc.myshopify.com/admin/api/2020-04/customers/"+{{customer.id}}+".json",
type: "PUT",
data: customerdata,
dataType: "json",
beforeSend: function(x) {
if (x && x.overrideMimeType) {
x.overrideMimeType("application/j-son;charset=UTF-8");
}
},
success: function(result) {
window.location.href = "/account/logout";
}
}); 

If this AJAX call return success result, then your customer info could have been updated successfully.

 

Regards,

Pon.

0 Likes
Highlighted
Shopify Partner
29 4 4

Dear @kamilski81 ,

I already have posted my answer here. It got deleted. I dont know the reason.

For your question, the answer is, i have fixed this issue by using following API.

https://shopify.dev/docs/admin-api/rest/reference/customers/customer?api[version]=2020-04#update-202...

For this to work, you need to create New Private APP in "Apps" section and get API key and password. After that using that info you could update the field(Email, First name, last name, password etc..) what you need.

 

Regards,

Pon.

 

0 Likes
Highlighted
Shopify Partner
29 4 4

Dear @kamilski81 

Did you try this approach? If it works, then please accept this as solution.

 

Thanks & regards,

Pon maheswaran K

1 Like
Highlighted
Tourist
4 0 2

Thank you. This is not my question to accept as an answer. This solution looks good but I haven't tried it yet cause we went in a different direction for our business.

1 Like