Easy and smart page builder: build any stunning, sales-ready pages - now supercharged with AI Install App  

Header background

How to Display Custom Content for Each Variant Using Metafields

Lina

Written by Lina

Last updated

67 views

On this page


Dynamic Product Content by Variant lets you display different content (descriptions, specs, size guides, media, promo labels, etc.) based on the variant a customer selects. It uses metafields/blocks to automatically switch the content, creating a smoother experience and reducing confusion. Result: customers understand the product faster and conversion rates increase.

Step 1: Create a Metafield

Go to Shopify Admin > Settings > Metafields and Metaobjects > Variants.

image57.png

Configure the metafield with the following options:

  • Name: Any name you prefer (e.g., “Variant Info”)

  • Namespace and key: theme.variant (required)

  • Content type: Choose Single-line text or Multi-line text, depending on the content you want to display.

Once saved, this metafield will appear in the variant details section of your products.

image58.png

Step 2: Add Metafield Content to Product Variants

Go to Shopify Admin > Products and open the product you want to edit.

In the Variants section, select the variant, then scroll to the bottom of the page to find the Metafields section.

Enter the custom content you want to display for this variant

Step 3: Display the Metafield Content in Your Theme

To make the content dynamically display for each variant, you’ll need to use the code below. Please follow the next part to know how to add

{%- if product.variants.size > 1 -%}
{%- assign selected_variant = product.selected_or_first_available_variant -%}
<hdt-variant-toogle-info product-id="{{ product.id }}">
  {%- for variant in product.variants -%}
    {%- if variant.metafields.theme.variant != blank -%}
    <div variant-id="{{ variant.id }}"{% unless selected_variant.id == variant.id %} hidden{% endunless %}>
        {{ variant.title }}: {{ variant.metafields.theme.variant.value }}
    </div>
    {%- endif -%}
  {%- endfor -%}
</hdt-variant-toogle-info>
{%- endif -%}

3.1. In the Product Information

To show Variants in the Product Information, go to Product Page > Main product > add Liquid - HTML Blocks, then paste the code inside the content box.

3.2. In a Product Tab

To show Variants in the Product Tab, go to Product Page > Main product tabs > add Tab custom liquid, then paste the code inside the content box.

🎁 Exclusive Deals for The4 Customers

EComposer

🎉 EComposer – Free 6-Month Plan

Build landing pages, sales funnels, and more with drag & drop.
The4 users get 6 months free (save $114) on Pro plan.

  • ✅ 100+ templates ready to use
  • ✅ Build any Shopify page
  • ✅ No coding required
🔓 Get 6 Months Free
SectionAI

🤖 EcomRise: Upsell & Bundles

Boost sales effortlessly with product bundles, upsell and cross-sell, buy X get Y, volume discounts

  • ✅ Easy upsell & cross-sell
  • ✅ Works with the latest themes
  • ✅ Trusted by 10k customers
🚀 Get 6 Months Free

Enjoy a free 3-day trial. Then get your first month for $1. Try Now

We uses cookies to ensure you get the best experience on our website.