Re: Assign a Metafield to SHOP to access within liquid templates

Assign a Metafield to SHOP to access within liquid templates

AHaas
Tourist
4 0 1

I am looking to add in Metafields that apply to the SHOP so that is accessible to anyone using the storefront.   From what I have read SHOP level metafields can only be created/managed via the GraphQL API.  Once I create a metafield definition using the API (which I need to get the keys via a new App development app) the namespace get prefixed with that app's ID.  Now when i try to access it via liquid i need to maintain that app id so i can do "shop.metafields['app--123456789--bark'].free_shipping_threshold".  We are also using the shop for our Native App so need to maintain the namespace there as well.  If we want to then create a new metafield via the GraphiQL interface in the storefront it will have a different namespace - now tied to that app's ID. 

 
My main question is:
 
Is there a way to create a SHOP level metafield that has a "universal" namespace not prefixed so that it can be shared across other apps as well as accessible in the Storefront's liquid templates? 
Replies 4 (4)

PaulNewton
Shopify Partner
7201 637 1497

With relevant permissions why not just create a regular metafield with an app identifiable namespace

https://shopify.dev/docs/apps/build/custom-data/metafields/manage-metafields#step-1-create-a-metafie... 

 

There is no such thing as a "universal namespace not  prefixed", that's a nonsensical oxymoron as a namespace that represents anything while also not existing is meaningless and not a namespace in any sense.

If you try to use common words as an apps namespace, or lack of it,  you only create an inevitable conflict as the apps customer base scales defeating the entire reason namespacing is important in software development itself.

 

Be clear be descriptive be non-ambiguous.

 

Prior to app-metafields and prior to private metafields there was an informal namespace registrar forum thread for app-devs to try and avoid naming conflicts but I believe that is lost to time but you could also search the partner slack for such things.

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


AHaas
Tourist
4 0 1

Yes - what i am looking for is to "just create a regular metafield" for the SHOP.  I have no issue creating it on products or collections but cant seem to find a way to create one on the shop (so that " they'll be accessible to any app").   Maybe having it located on the shop is the wrong approach but not sure what other resource would be appropriate for something that is on the Store level.

PaulNewton
Shopify Partner
7201 637 1497

Just make sure the app have relevant permissions, or find out what the error is.

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


AHaas
Tourist
4 0 1

im not sure I follow?  the issue isnt that it cannot be read or that there is an error.  Im just trying to create a regular metafield on my shop so that it can be referenced in it's liquid template or a similar architecture so that it can be accessed without a prefix