Using metafields
Metafields帮助你定制功能and appearance of your Shopify store by letting you save specialized information that isn't usually captured in the Shopify admin. Metafields can be used internally in your Shopify admin and you can also choose to display them in your online store. Here are some examples of metafields and where you can use them:
- Create shipping instructions for products, such as information on packing material, for your product page in your Shopify admin.
- Create estimated processing or shipping time, such asShips in 1 day, and display it on your product pages in your online store.
- Add color information for products, such as red, black, or blue, and display it on your product pages in your online store or use it to createautomatic collections by metafields.
You can add metafields to your products, collections, customers, orders, and other parts of your store, directly from your Shopify admin.
If you have anOnline Store 2.0 theme, then you can connect most metafields to your theme by using the theme editor. If you're using vintage themes, or if you want to add metafield types that your theme doesn't support, then you canedit your theme codeor hire a Shopify Expert to help you. Learn more about hiringShopify Experts.
On this page
Product care instructions tutorial
In this tutorial, you learn how create a metafield for product care instructions and display them on your online store.
- 你将学习
- Step one: Create a metafield definition
- Step two:一个dd values to metafields
- Step three: Publish your metafield on your store
你将学习
After you've finished this tutorial, you'll have accomplished the following:
- Created a metafield definition
- Added values to metafields
- Published your metafields
Step one: Create a metafield definition
- From your Shopify admin, go toSettings>Custom data.
- UnderMetafields, clickProducts.
- ClickAdd definition.
- Name your metafield definitionCare guideand click the standard metafield definition that is displayed. Learn more aboutstandard metafield definitions.
- UnderAccess options, checkStorefront. This allows the content you create to be accessed and displayed by your online store.
- ClickSave.
After your metafield definition has been saved, you can startadding values to metafields.
Step two: Add values to metafields
- From your Shopify admin, go toProducts.
- Click a product that you want to have care instructions.
- InMetafields, clickCare guide. Enter the care instructions.
- ClickSave.
Repeat the steps above to add values to your metafield in other products.
Next, you willpublish your metafield to your online store.
Step three: Publishing your metafield to your online store
Now that you've added values to your metafields for your products, it's time to display your metafield on your store. This step uses the theme editor to select the blocks and sections where your metafield will be linked to.
After you add a section or block, you can select a metafields by clicking the connect dynamic source icon:
- From your Shopify admin, go to欧宝体育官网入口首页>Themes.
- Find the theme you want to edit, and then clickCustomize.
- Use the drop-down menu at the top of your screen to selectProducts>Default product. This loads the default product template in the theme editor.
- In theProduct informationsection, clickAdd block>Collapsible row.
- Enter a heading.
- Optional: Choose anIconfrom the list or clickNonefor no icon.
- Next torow content, click theConnect dynamic sourceicon and selectCare guide.
- ClickSaveto publish your product care instructions.
Your care instructions will only display on the products they are connected to and the section is not filled in for any products without a value for that metafield. That means you can set up a single product template that will work for all your products.