A user is attempting to display variant-level metafield data (realism, tree shape, height, width, warranty, tip count, light count) in collapsible product description rows on their Shopify store using the Trade theme. They’re encountering an “invalid” error when trying to reference variant metafields through the theme editor’s dynamic source feature.
Core Issue:
Shopify’s theme editor only supports product-level metafields as dynamic sources—not variant-level metafields. The dynamic source picker cannot access variant.metafields.* references.
Proposed Solutions:
Option A: Move metafields to product level if all variants share the same values
Option B: Use custom Liquid code in the product template:
Option C: Install a third-party app like “Variant descriptions”
Option D: Implement a custom web component solution (provided by tim_1) that listens to variant change events and updates content dynamically
Current Status:
The user attempted tim_1’s custom code solution but reports it doesn’t update when switching between variants (e.g., height remains “4’” regardless of selection). They’ve requested additional help and been asked to share a preview link for further troubleshooting. The user is unfamiliar with editing theme template files directly.
Summarized with AI on October 23.
AI used: claude-sonnet-4-5-20250929.
Hi! I am using the Trade them for my website and when trying to reference variant metafield attributes to add into the item descriptions I am getting the error:
Can anyone tell me what I am doing wrong so that I can reference these variant level attributes when a customer select a certain variant on my product page?
Make sure you’ve created a metafield called realism under namespace: custom (so its full key is custom.realism). If it’s under Products, not Variants, you must reference it as:
product.metafields.custom.realism
not variant.metafields.
2. Ensure you’re in a variant context
Inside the product page, the “Collapsible row” block’s dynamic source doesn’t automatically know which variant is active.
Dynamic sources (like the editor “Connect dynamic source” button) only pull product-level metafields — not variant-level ones.
That’s why variant.metafields... gives an invalid error in the editor. Important: Shopify theme editor only supports product metafields as dynamic sources — not variant metafields.
Solution options Option A – Move metafield to the product level
If all variants share the same value, just move realism to Product metafields instead of Variant metafields.Option B – Reference via code (for variant-specific values)
Edit your theme file manually:
Open Online Store → Edit code.
In your product template (main-product.liquid or similar), locate where you want to show the metafield.
That will output the value for the selected variant dynamically.
Would you like me to show exactly where to add that code inside your Trade theme’s collapsible row so it displays properly per variant?
If yes, please tell me:
You are displaying variant-specific metafield data in your product descriptions.
Meanwhile, Shopify’s theme editor can only support product-level metafields as dynamic sources.
For variant-specific data, edit your theme file by adding this code snippet in the product template file:
This should display the metafield value for the selected variant.
If you wish to go a step beyond and add custom Shopify product attributes that directly map to the Merchant Center, we recommend using a Built for Shopify app, like AdNabu.
It automatically syncs the updates and follows Google-compliant policies for zero product disapprovals.
I did try this but it does not update as I click through the variants. For example, another variant metafield I am trying to load is custom.height and using you code it only displays “ 4’ ” and when I click on the 6 foot or other height options the value does not change accordingly like I need it to.