|
14
Dec |
|
Caroline |
We’re excited to announce that we’ve just rolled out the ability to attach metadata to a shop’s resources using the Shopify API. This means Shopify app developers can now store additional information about products, collections, orders, blogs, pages… and the shop itself. We’re calling this feature metafields. For the time being, you can only add these metafields and edit them using the Shopify API. Some time from now, we will make it possible for a shop owner to manage them from the admin interface. The ability to use metafields in a Shopify theme has already been implemented. So you can output and use metafields in your Liquid templates (including email templates), provided you’ve added them using the API. Our API documentation has been updated to show you how to add, edit and delete metafields. Check out the API Documentation page on MetaFields. A metafield consists of a namespace, a key, a value, and a description (optional). Use the namespace to group different metafields in a logical way. You can also specify that it is either an integer or a piece of text (a “string”). In this way, you’ll end up with the right type when you use it in your Liquid. Say you’ve added to a product a metafield with the following attributes:
You can output the value of this metafield in product.liquid with this Liquid tag:
There is currently no limit imposed on how many metafields you can attach to any piece of content. If you’re a Ruby on Rails developer, our shopify_api gem will get you started with adding metafields. Take a look at the Metafields module defined in shopify_api.rb. Using the Metafields module, setting a metafield on a product is as easy as this:
Metafields can be used to further describe products, beyond the product description, type, vendor and tags. You can also use metafields to store a ‘teaser’ or ‘summary’ for a blog post. App Store developers can also use metafields to share information between multiple applications. The possibilities are limitless. We’re inviting you to share your ideas on how to use metafields with the rest of the Shopify’s community in our Community forums. Update: Metafields can now be added to product variants as well. |


10
Comments (10)
Are these meta fields exported with products csv?
December 14th, 2009 at 12:19 PM
Is metafields the way to create a multilingual shop?
December 14th, 2009 at 01:33 PM
Jamie: metafields are not exported with the products CSV.
Anders: there are still a few gaps which keep it from being a perfect solution, but we encourage people to experiment along these lines.
December 14th, 2009 at 02:50 PM
Great news. Is there an ETA for the admin interface? We’re developing a site over the holidays that would really benefit from this.
December 14th, 2009 at 02:55 PM
Hi Alex,
I doubt very much that Metafields will make it to the admin screens on time for the holidays, Christmas being next week. It’s easy (enough) though to write a Shopify app to set those for your shop. You can already read the metafields using Liquid in your theme.
Anders,
You asked: “are metafields the way to create a multilingual shop?”
Metafields are a step in the right direction I think. You can add translations for all of your content (blog posts, product titles and descriptions, etc.) However, you will still need JavaScript to hide/reveal the bits and pieces that are in the ‘right’ language, add a language-switcher to your theme and store the picked language in a web cookie… you will have to take care of all this and more… You will need to translate your navigation items and your UI… Also, take note that checkout is still in only one language, that you get to pick of course, but you can’t translate the language used on checkout pages ‘on the fly’...
Jamie,
Hi there! :-)
[EDIT] You can store your UI and navigation translations as shop’s metafields. I forgot that. The shop itself can have metafields attached to it.
December 15th, 2009 at 10:35 AM
Can these Metafields be added at the variant level?
Thanks in advance.
December 15th, 2009 at 05:54 PM
Hi Alex, metafields can only be attached to these pieces of content:
Order Product Custom Collection Smart Collection Page Blog Blog Article Shop
So, no, you can’t add these to a variant.
December 18th, 2009 at 06:38 PM
Actually, leaving out product variant metafields was an oversight. We added them to the system yesterday, so they are now indeed available.
December 21st, 2009 at 01:03 PM
I hate to nag, but is there any ETA on when this will be available in the admin screen? I’d prefer to not have to learn Ruby just to hack together a way of submitting data.
Metafields sound awesome – can’t wait to be able to use them :)
January 9th, 2010 at 04:19 PM
Love it, haven’t tried them yet but I’m dying to find time :-) Will the metafields ever be exported with the product information or is there a reason we can’t do that?
January 12th, 2010 at 09:11 AM
Sorry, comments are closed for this article.