Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
I'm creating a shopify app that will take some user (the merchant) specified input box text from the app dashboard gui, (this is an embedded app), and use it to populate an app block which i wish to place in the cart page of a store. I've created the front end dashboard part of the app, and I know how to create the app block liquid code as an app extension. What I'm not sure about is how to transfer this data to the app block to be used. ChatGPT has told me that metafields are a viable option. I've found very little information on creating metafields entirely in app code. For now I'd just like to know if this should be possible using metafields, or if there is another easier way to do it.
Thank you
Dak
Hey bro I just created my first app! I ran into the same issue and found no content about it
Maybe I should make a YouTube video about this
You can use metafields or metaobjects
You can find the documentation here
Basically the way it works is you create a metaobject definition which is essentially a schema
Here are the docs for creating a definition here
Then you can add or remove metaobjects. You can find the documentation on how to do Everything
And you can access it from theme app extension using This
hey,
thanks a lot man, I'll have a look!
My stuff is just text, so I would think a metafield could be used instead of a metaobject. But it's enough to know that you got your app working using this method.
I checked out YouTube videos comparing metafields and metaobjects
and I found that metaobjects are the best for apps because they offer this only your app can access the data
I was in your shoes just four days ago so I know how frustrating it can get If you run into any problems just let me know and I'll reply as soon as possible
hey thanks man! I'll take more of a deep dive into this before I bug you anymore on here lol
No problem bro Feel free to ask as much as you want
So I finally had a chance to look at this again, and I had some questions about getting started. I'm building my app using the Express App template. I'm kind of a backend newbie, although I know the basics. So looking at the sample nodejs code for creating a metaobject definition, as per your second link, I'm guessing it would have to be placed in the server file, so app/web/index.js. ? Also would that sample code need to be wrapped in an endpoint? So something like this: