Use metafields on product pages
This guide describes adding a metafield into a product page template, to display additional information about a product on a store's product page.
For example, in the following image, a custom metafield displays the manufacturer's part number MPN: 12345 for a product on a store's product page.
Metafields store information. For example, you can create a metafield to store information about a product's physical dimensions. By adding metafields to blocks inside a product page template, the information from the metafields can be displayed on your store's product pages. Refer to Shopify help: Using metafields and dynamic sources.
To specify the information that's stored in a metafield, shopify provide standard metafield definitions. Refer to Shopify help: Adding standard metafield definitions .
You can also create custom metafield definitions. Refer to Shopify help: Creating custom metafield definitions.
As an example, this guide creates a custom metafield definition to store a manufacturer's part number (MPN) for a product. The MPN is displayed inside a text block on a product page. To create a different custom metafield, adapt the steps in this guide to suit your requirements.
Define a product metafield
To define a product metafield:
In your store's admin, go to Settings > Metafields.
On the Metafields page, select Products, and then choose Add definition.
In the Name text box, enter a name for the metafield.
For example, to create a metafield for a manufacturer's part number (mpn), in the Name text box, enter mpn.
You can also select a standard definition with a content type that corresponds to the information you want the metafield to store. For example, Shopify provide standard definitions for storing International standard book numbers (ISBN), Product guides, Product subtitle, etc.
For a list of standard definition and content types, refer to Standard metafield definitions.
[Optional] In the Description text box, enter text to describe the metafield. For example, enter Manufacturer's part number.
Choose Select content type.
From the list, select the type of content for the metafield to use.
For example, to set the mpn metafield to store numbers, select Number from the content type list.
Where relevant, set the required options and validation rules to define the metafield.
For example, to set the mpn metafield to use five digit intergers, select the Interger checkbox. In the Minimum value text box, enter 00000. In Maximum value text box, enter 99999.
Depending on the metafield's content type, different options and validation rules are displayed.
Select Save from the Unsaved changes menu at the top of the page.
Set values for the metafield
To set values for the metafield:
The steps required to set values depend on the metafield's content type. Refer to Adding values to metafields. Adapt the following steps to suit your requirements.
In your Shopify admin, select Products.
Select a product from the product list.
At the bottom of the page, locate the Metafields area.
Select a metafield from the list, and then enter the required values.
For example, select the mpn metafield, and then enter the value
12345into the text box.
Depending on the metafield's content type, different options are displayed for entering values. Refer to Adding values to metafields.
Add the metafield to product pages
To add the metafield to a product pages' block:
In theme editor, at the top of the page, use the dropdown to select a page that contains a Product pages section. Refer to Product pages.
For example, select Products > Default product > Product pages.
From the Product pages section menu, select a Text or Rich text block to contain the metafield.
Alternatively, to add a new block, select Add block > Text or Rich text, and then select the block you added. Refer to Configure, add, remove, hide, or move a block.
Inside the block settings menu, select the icon Insert dynamic source.
From the Insert dynamic source menu, select a metafield, and then choose Insert.
For example, select the mpn metafield.
[Optional] In the Text box, enter a prefix for the metafield value. For example, in the text box, enter the prefix MPN:.
Verify that the metafield displays on the product page.
To set how the block containing the metafield is displayed, refer to Configure, add, remove, hide, or move a block.
To set how the metafield displays on all product pages, refer to Settings > Products, and Shopify help: Displaying metafields on your online store.