Re: Storefront // Allowing customers to update metafields

Storefront // Allowing customers to update metafields

Chris_Sydney
Shopify Partner
103 4 20

Hey,

 

Wondering if there is a way to allow customers to update metafields on the customer record, I was thinking i could write this via the admin API, but there doesn't seem to be a scope for metafields on customers, so it looks like i would need to give access to write customers, which is a little too much scope for my liking. 

 

Ideally I would like to add details (date of Birth, Products, etc) to their customer profile. 

 

 

Replies 9 (9)

SBD_
Shopify Staff
1831 273 418

Hey @Chris_Sydney 

 

You'd need that scope to write to customers. Perhaps you could combine it with an app proxy (which includes the logged_in_customer_id) to validate the customer.

Scott | Developer Advocate @ Shopify 

Chris_Sydney
Shopify Partner
103 4 20

Hey SBD,

 

Thanks for you comments, I haven't actually dabbled in app proxy and that might work from a validation standpoint (both of customer id and server), which then i can constraint further on access. 

 

ill report back after i read the guides.

is this only available on partner portal or site as well? 

SBD_
Shopify Staff
1831 273 418

Hey @Chris_Sydney 

Awesome, good luck!

is this only available on partner portal or site as well? 


Can you please elaborate?

Scott | Developer Advocate @ Shopify 

Chris_Sydney
Shopify Partner
103 4 20

Thanks, I mean can the storefront API get access to this?

SBD_
Shopify Staff
1831 273 418

Ah, got you! For the Storefront API, you could do something like test the customer's credentials with the customerAccessTokenCreate mutation, and keep track of their customer ID in a session.

Scott | Developer Advocate @ Shopify 

Chris_Sydney
Shopify Partner
103 4 20

Hey, 

thanks for the info, let me whip up a script on this and give it a whirl 🙂

 

FYI - I prob just hold the customer id in sessionStorage or such and then setItem on login and removeItem on logoff.

 

The Node on the other side of this is pretty restricted anyways. 

PaulNewton
Shopify Partner
6910 619 1455

There is no native supported way to update any non-customer-address data from the frontend, without an order being placed; or someone creating a new customer account possibly with tags added to it's forms during it's creation from the frontend for use in logic.

 

If your not building an app yourself look at either customer-fields in the app store, or something like usemechanic to script a simple frontend form.

 

For shopify-flow there is also no actions like contact-form-submitted, or customer-updated etc etc that would let us do a workaround like using the address system to trigger the update-customer-metafield  action.

Hypothetical spitball: there is the schedule-time trigger(minimum 24hrs) which could use the get-customer-data once every day reading in an overloaded address which you would want to blank as soon as it's processed.

 

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


Chris_Sydney
Shopify Partner
103 4 20

Thanks for your response. 

 

effectively like a form sounds kind of right, I was hoping that flow had that functionality but it doesn't. 

 

I could definitely build the app, but it kind of seems like a missed opportunity for custom metafields, and was wondering if there is something out there.

 

Current working idea is to effectively create a webhook in javascript (using fetch), and then catch the webhook on a node server, validate the webhook payload and then use node to send it to metafields on the customer record.

 

I think latency should be ok-ish... only way to know is to test it out. 

kjchabra
Shopify Partner
26 1 6

@Chris_Sydney not sure if you are still looking for a solution to this.

 

We at Clouver ran into a similar problem and ended up creating an app that you can install that makes it possible for store customers to update their own metafields. You do need an AWS account (lambda functions to make shopify admin api calls) but all the backend and authentication setup is handled by the app.

 

Happy to answer any questions.

Thanks.