Want to store privateMetafields with Shopify resources and access them in liquid files

sagar_ranglani
Tourist
6 0 1

I want to store privateMetafields with Shopify resources and access them in liquid files!

I don't want to expose data to other apps or merchants so storing in metafields is not an option. But I can't seem to access privateMetafields from liquid templates,I read in the docs that

1. privateMetafields can't be accessed from liquid files

2. meta fields can be read/edited by accessed by merchants or other apps

Now, using meta fields to store dynamic data for Shopify resources is a security risk and privateMetafields can't be accessed from liquid so it kinda defeats the purpose! I would need to have an API call or something to get data into templates.

Any help would highly be appreciated.

Thank you very much.

 

Replies 2 (2)
axis80
Shopify Expert
13 1 2

I am running into this exact same issue.  I want to use the new Theme App Extensions so that customers can add my app blocks within the theme customizer.  I can pass the data to the theme extension's Liquid templates through public JSON metafields, however that is going to confuse storeowners when they see it.  I would much rather store it in private metafields so they don't have to see it, and so they can't mess things up by trying to edit it.

sercanov
Tourist
4 1 0

Same blocker, I also mentioned in https://community.shopify.com/c/shopify-apis-and-sdks/how-to-store-external-api-key-with-theme-exten...

I was happy with ScriptTag implementation. Online Store 2.0 and Theme Extensions isn't featured enough for my business logic, or I'm missing something for weeks.