Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

How to access the customer metafield in Customer account UI extensions

Solved

How to access the customer metafield in Customer account UI extensions

Hirano_00
Shopify Partner
86 10 13

I have used the Customer account UI extensions to access the customer metafield with the Storefront API from a full page, but it seems not to be possible because there is no unauthenticated_read_customers in the scope.

Storefront API access scopes

Your extensions will have the following unauthenticated access scopes to the Storefront API:

  • unauthenticated_read_product_publications
  • unauthenticated_read_collection_publications
  • unauthenticated_read_product_listings
  • unauthenticated_read_product_tags
  • unauthenticated_read_selling_plans
  • unauthenticated_read_collection_listings
  • unauthenticated_read_metaobjects

 https://shopify.dev/docs/api/customer-account-ui-extensions/unstable/configuration#api-access

 

 As an alternative, I considered using network access to access the customer metafield.

The documentation for network access reads as follows

Alternatives to network access

Instead of fetching data with an external network call, consider retrieving the data from a metafield. Your app may be able to use the Admin API to write metafields on the shop, product, or customer.

 

Retrieving data from metafields in new customer accounts is faster since it won't introduce an external network call. This allows you to rely on Shopify for the uptime, scaling, and durability of the data storage.

https://shopify.dev/docs/api/customer-account-ui-extensions/unstable/configuration#network-access

 

This seems contradictory.

Is there a way to access the customer meta field in the Storefront API from a full page using the Customer account UI extensions?

 

Accepted Solution (1)

Hirano_00
Shopify Partner
86 10 13

This is an accepted solution.

Replies 4 (4)

Hirano_00
Shopify Partner
86 10 13

This is an accepted solution.

lynth
Shopify Partner
140 6 16

Hey, could you explain what was the problem? The scope or implementation? Is it possible to reach the customer's metafield from checkout using the checkout UI extension?

If my tips are useful, just mark it as the solution. Cheers!
Feeling grateful? Buy me a coffee!
Hirano_00
Shopify Partner
86 10 13

I remember being able to access customer metafields by fetching from "shopify://customer-account/api/unstable/graphql.json" while using the customer account UI extension. However, I am not sure if it's possible to access customer metafields with the checkout UI extension.

lynth
Shopify Partner
140 6 16

Ok, thanks. I'm able to access it now with checkout UI, but the problem is I'm still unable to overwrite the customer metafield with a new value. I can only read it.

If my tips are useful, just mark it as the solution. Cheers!
Feeling grateful? Buy me a coffee!