All things Shopify and commerce
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?
Solved! Go to the solution
This is an accepted solution.
Hi @hookbeak ,
You can create a "global storage" by creating a metafield for shop object
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 }}
This is an accepted solution.
Hi @hookbeak ,
You can create a "global storage" by creating a metafield for shop object
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 }}
thanks man, that's great.
You're welcome! It's nice to see that my reply was helpful 🙂
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):
thanks - i've added it and used it to create my metafields!
nice way, thanks
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024