Adding a pop-up to your product pages with metafields
Metafields help you to customize the functionality 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.
With metafields, you can add a page reference to a pop-up block that displays a link on your product pages. When clicked, the link opens a pop-up that displays your page's content. You can add images and other media using the rich text editor for your pages.
The following are some examples of pop-up information you could add to your product pages:
- Size charts
- Care instructions
- Assembly instructions
- Product specifications
- Frequently asked questions
This is a 4-step tutorial that introduces page reference metafields, creating a product metafield for a page reference, creating a product page template for your online store, adding a new page, referencing the page in specific products, and applying the product page template to specific products.
If you have an Online Store 2.0 theme, then you can connect most metafields to your theme by using the theme editor. If you're using a vintage theme, or if you want to add metafield types that your theme doesn't support, then you can edit your theme code or hire a Shopify Partner.
On this page
Step 1: Create a product metafield for a page
To begin, you must create a page reference metafield definition for your product pages. The product metafield links to a specific page and can be customized for each product. If you don't add a page reference to a product that uses the same template, then your pop-up link text still displays as though there is content. In order to only display the pop-up link on specific products, you can create a product template and apply that only to relevant products.
With page reference metafields, you can display different product information by creating different pages for different types of products. For example, you can create two different size chart pages for two different age groups, such as a toddler size chart and an infant size chart, and then you can add the page reference for toddler sizes only to products that are for toddlers.
You need to create a metafield definition for a page reference in order to connect it to the pop-up block in your theme editor. Storefront access is selected by default when you create your metafield definition.
Steps:
Step 2: Create your product page template
If you have an Online Store 2.0 theme, then you can connect the page reference to your theme by using the theme editor. If you're using a vintage theme, or if you want to add metafield types that your theme doesn't support, then you can edit your theme code or hire a Shopify Partner.
After you add a section or block, you can select a metafield by clicking the dynamic source icon:
If you don't want to add the pop-up block to all your products, then you need to create a new product page template. In the steps, you create a new product page template, but you can also choose an existing product page template to customize instead.
Steps:
Step 3: Add a page with your product information
You need to create a page with content that the metafield references. If you already have a page created, then you can skip to step 4.
Steps:
You can create as many pages to reference in the metafield as you need. However, you can link only one page in the product metafield.
Step 4: Reference the page and apply the product template to specific products
When you add a page reference to a specific product, the information from that page displays only with that product. If you leave the page reference blank for a product that uses that product template, then the link text still displays as a link. However, the pop-up is blank with no page reference and might create confusion for your customers. In this case, you can use a different product page template for specific product types. For example, you could create a product template for clothing with the size chart page in your pop-up block, and then you could create a product template for bags where you don't need to add the pop-up block.
Learn more about templates.
Steps:
You can repeat these steps for as many products as you need.