Add text when metafield is selected

Topic summary

A user needed to display dynamic text on a product page based on selected metafield values, specifically wanting different brand descriptions to appear when different brands are chosen.

Solution Found:

  • The issue was resolved using Liquid templating code
  • Implementation involves conditional statements checking metafield values
  • The code uses {% if product.metafields.namespace.key == 'TypeA' %} syntax
  • Different text blocks display based on which metafield value matches

Technical Approach:

  • Place code in the relevant Liquid template file
  • Customize the namespace and key parameters to match your metafield structure
  • Use conditional logic to switch between different text content

The discussion is marked as resolved, with the working code snippet provided for implementation.

Summarized with AI on November 11. AI used: claude-sonnet-4-5-20250929.

I want to add text to a product page depending on the metafield that is selected.

So on the page below I want to add a text about the brand, but when another brand is selected I want to have a text about that.

How can I make that possible?

https://roundmusic.nl/collections/elektrisch?sort_by=best-selling&filter.p.m.custom.merk=Sire

ChatGPT has fixed this problem for me. Place the code below and change the namespace and key into the liquid file you want.

Code:
{% if product.metafields.namespace.key == ‘TypeA’ %}

text for TypeA.

{% elsif product.metafields.namespace.key == 'TypeB' %}

text for TypeA.