Solved

How to store customer additional details in meta fields and show them on account page.

sbdev
Shopify Partner
48 0 10

Hello,

I am a Shopify developer and have seen a lot of questions asked about how to use meta fields to store additional information of customers and how to retrieve them in the account page.
I know about customer notes but they cant be retrieved on the account page.

I assume that Shopify staff is ignoring these questions so that people can rely on the apps.

But I would like to request all the experienced developers to help me with the syntax that how to get customer data in the meta fields, and how the syntax that how to retrieve this by using customer object/meta fields on the account page. I had a word with some developers and we only know that the way exists to store and retrieve additional information of customers but not aware of the syntax and not able to find an informational source to understand this better.

Also do not suggest any kind of app as I currently do not want to use it.

I am stuck and hoping for help from the community.

Thanks in advance.

 
 
Accepted Solution (1)

Jason
Shopify Expert
11190 225 2282

This is an accepted solution.

Have you taken a look at the API docs for this?
https://shopify.dev/docs/admin-api/rest/reference/metafield

That gives you a pretty good starting place for any calls you need to make. I can understand if you don't want to use existing apps given that you're a dev but you will need to use the API and create your own. Unlike things like line item properties, or order notes, metafields do require the API to add. There is an exception here that you can use the bulk editor in the Admin to add metafields but really that's still using the API.

As for showing it on a customer account page when they log in, that will just take a template tweak. Take a look at the Liquid docs for the syntax:
https://shopify.dev/docs/themes/liquid/reference/objects/metafield

And customer notes are only every intended to be merchant facing so - as you've found - they don't get exposed in Liquid objects.

 

I assume that Shopify staff is ignoring these questions so that people can rely on the apps.

That's not the case at all.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★

View solution in original post

Replies 4 (4)

Jason
Shopify Expert
11190 225 2282

This is an accepted solution.

Have you taken a look at the API docs for this?
https://shopify.dev/docs/admin-api/rest/reference/metafield

That gives you a pretty good starting place for any calls you need to make. I can understand if you don't want to use existing apps given that you're a dev but you will need to use the API and create your own. Unlike things like line item properties, or order notes, metafields do require the API to add. There is an exception here that you can use the bulk editor in the Admin to add metafields but really that's still using the API.

As for showing it on a customer account page when they log in, that will just take a template tweak. Take a look at the Liquid docs for the syntax:
https://shopify.dev/docs/themes/liquid/reference/objects/metafield

And customer notes are only every intended to be merchant facing so - as you've found - they don't get exposed in Liquid objects.

 

I assume that Shopify staff is ignoring these questions so that people can rely on the apps.

That's not the case at all.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★
sbdev
Shopify Partner
48 0 10

Hello @Jason,

Thank you for checking out with this. I highly appreciate your response. And yes I knew that we can store it in the metafields and retrieve by some way. My and I guess many developer's questions is what is the approach of doing this. Are we going to create a metaffield for each customer separate or will push all customers in same. How are metafields going to be connected with the specific customer ?

Should we fire the API on the register button of a form?
I am unable to find any example which shows the approach or any other information that this will going to be executed.

Can you help with that also ?
Any developer who have done this can help us with?

I am stuck and I will highly appreciate your help.

Thanks for hearing me.

kk8
Visitor
2 0 3

Hello @sbdev & @Jason ,

may i request for an example how to allow customer to modify the metafield on account(registration) liquid template?

For example: i want to change the liquid template below saving field value from customer notes to customer metafields 

<div id="gender-wrapper" class="clearfix large_form">
<label for="gender" class="label">Gender</label>
<select id="gender" name="customer[note][gender]" value="">
<option value="Male">Male</option>
<option value="Female">Female</option>
<option value="Notmention">Rather not to mention</option>
</select>
</div>

<div id="birthday-wrapper" class="clearfix large_form">
<label for="birthday" class="label">Birthday</label>
<input type="date" value="" name="customer[note][birthday]" id="birthday" class="text" size="30" />
</div> 

Jawa
Shopify Partner
3 0 0

saving field value from customer notes to customer metafields 
This is also what we are looking for. Did you find any solution other than API call?