Using metafield information on store front

New Member
2 0 0

Hello,

I've used metafield api to add a custom information to a product using the app. Now I need to get that information on store front, using the ScriptTag.

I've really tried but haven't found any other way to access that information other than making the app "Sales channel" which is unnecessary in this kind of app.

Can I somehow access that metafield information using script tag in other way than by editing template? (Don't want to force my users to edit their templates because of an app).

Other way I can use is to store it in my own database - can I do that? But I would rather stick with the metafield api.

Thank you,
Tomas

0 Likes
Highlighted
Shopify Staff
Shopify Staff
1555 80 254

You could consider using the Storefront API via your ScriptTags if you want to make publicly authenticated requests: https://help.shopify.com/en/api/storefront-api/reference/object/metafield

 

I would not recommend hitting the Admin API from the client on a storefront for security-related reasons, since you wouldn't want your API key/secret or Access Token exposed in the DOM.

 

As an alternative, you could make authenticated Admin API requests from your back end, as initiated by one of these script tags on the storefront, delegating the actual authenticated API request to your secure environment.

 

Cheers.

0 Likes