Use Metafield in APP

Highlighted
Shopify Partner
14 0 0

I have created Metafield using API. Currently accessing those Metafields in shopify cart.liquid like given below -
{{ shop.metafields.AnnexCloud.access_token }}
But when I try to access Metafield through above syntax in APP files facing issue.

So, please help me out.

Thanks

0 Likes
Highlighted
Shopify Partner
1777 211 370

Hey there,

 

What is the issue you are facing specifically?

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
Highlighted
Shopify Partner
14 0 0

Hi @Visely-Team actually I am going to create different Apps for different module. But all Apps need some common values. So, I created one configuration App for saving common values in metafields rather than saving in each App. Let consider one of metafield is for Site_ID. Now I need to access this Site_ID from my configuration App to another App's front-end code

0 Likes
Highlighted
Shopify Partner
1777 211 370

Sorry, I wasn't referring to the actual problem/functionality, but rather the errors you get when trying to fetch metafields "from" APP. Are you using REST API or GraphQL? Can you share the concrete requests you are making?

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
Highlighted
Shopify Partner
14 0 0

As I mentioned need to access meta fields which were created through another App. In the same App able to get the meta fields using the following request
headers = {
"X-Shopify-Access-Token": session.get("access_token"),
"Content-Type": "application/json"
}
response = requests.get("https://34de4c8c.ngrok.io".format(session.get("shop"),"/admin/metafields.json?key=site_id"), headers=headers);

0 Likes
Highlighted
Shopify Partner
1777 211 370

OK, and what is the error you get when you try to access metafields from a different app? In general, metafields can be written and read by any apps and are not restricted. Does the other app has the correct access scope to access shop information?

 

Also, Shopify has recently introduced private metafields, but this is not your case so I assume there is a misconfiguration.

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
1 Like
Highlighted
Shopify Partner
14 0 0

Well, the App in which I want to access meta fields is not ours. Implementing the changes in App called "Recharge Payment". Want to fetch some data using our API at the admin end files of Recharge Payment app (attached screenshot). You can see the access token in that API is static. I have created one app, using that created a meta field for the access token. Now, instead of static access token in API want to use meta field

2019-07-12_1120.png

0 Likes