Re: A metafield available site wide?

Solved

Is it possible to store and use a single value site wide in various places?

hookbeak
Shopify Partner
15 1 6

I need to pass a a single value via the api into shopify and store that value.

 

I will then use that value in numerous places: product pages, pages, snippets etc

 

Is this possible? I thought of storing it as a pages metafield - but then it's only accessible *on that page*

 

i can't believe there's no way to have a site wide variable - so what am i missing?

Accepted Solution (1)

MetafieldsGuru
Shopify Partner
160 32 102

This is an accepted solution.

Hi @hookbeak ,

 

You can create a "global storage" by creating a metafield for shop object

MetafieldsGuru_0-1657721180514.png

Once a shop metafield is created, you can access its value from pretty much any place. No matter what template file you're editing, a shop metafield is available globally and can be accessed with the code of the following format:

{{ shop.metafields.namespace.key.value }}

 

Check out Metafields Guru, the #1 ranked metafields app.

Bulk editor | Data import/export | Metafield sets | Browser extension

View solution in original post

Replies 6 (6)

MetafieldsGuru
Shopify Partner
160 32 102

This is an accepted solution.

Hi @hookbeak ,

 

You can create a "global storage" by creating a metafield for shop object

MetafieldsGuru_0-1657721180514.png

Once a shop metafield is created, you can access its value from pretty much any place. No matter what template file you're editing, a shop metafield is available globally and can be accessed with the code of the following format:

{{ shop.metafields.namespace.key.value }}

 

Check out Metafields Guru, the #1 ranked metafields app.

Bulk editor | Data import/export | Metafield sets | Browser extension
hookbeak
Shopify Partner
15 1 6

thanks man, that's great.

MetafieldsGuru
Shopify Partner
160 32 102

You're welcome! It's nice to see that my reply was helpful 🙂

Check out Metafields Guru, the #1 ranked metafields app.

Bulk editor | Data import/export | Metafield sets | Browser extension
MetafieldsGuru
Shopify Partner
160 32 102

By the way, you don't necessarily have to use the API to create a single metafield. You can easily do that with our awesome app (even on the free plan):

MetafieldsGuru_1-1657721635260.png

Check out Metafields Guru, the #1 ranked metafields app.

Bulk editor | Data import/export | Metafield sets | Browser extension
hookbeak
Shopify Partner
15 1 6

thanks - i've added it and used it to create my metafields!

 

upserve
Shopify Partner
28 0 0

nice way, thanks

If helpful then please Like and Accept Solution.
Want to modify or custom changes on store Hire me.
- Feel free to contact me on https://ua.linkedin.com/in/yanchuga regarding any help
Shopify Partner | Telegram : https://t.me/yanwinner