Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
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
Solved! Go to the solution
This is an accepted solution.
Dear @kamilski81 ,
yes. it can be updated using following API.
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.
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
Did you end up finding out whether a customer can update their email on the Shopify site?
This is an accepted solution.
Dear @kamilski81 ,
yes. it can be updated using following API.
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.
Dear @kamilski81
Did you try this approach? If it works, then please accept this as solution.
Thanks & regards,
Pon maheswaran K
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.
Hi Pon!
I tried with your solution but I encountered a cors error like this.
How can I solve this problem?
If you have a solution to solve this problem, please let me know.
Thanks
Regards
How do you fix the cors problem, I met too.
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.
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.
Although the spoken API is the way to go for, the API key & Password shouldn't be exposed in client side. Instead, client side makes a web form and make a post request with sufficient customer id and certain hashed value to act as authentication, so then the private app in the server side validate such form submit is authenticated and valid for a profile update, and then process the spoken API call from the server side to get rid of the CORS (cross-origin resource sharing) security rule.
The API credential should never expose in client side.
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025