Hello,
I would like a text block to be shown when a particular variant is selected. I have seen that this should be possible using metafields, but I am not clear on how to display a particular metafield based on the selected product variant. Can anyone chime in with some assistance please ?
You either need to have the theme customized, or use a custom-liquid custom-html block that contains suitable javascript logic to change what’s displayed without having to reload the page.
Text blocks are static when added in most themes. They are then either on or off in the setting, they are not dynamic on the frontend based on other interactions or conditions. Unless a theme is specifically designed or customized to do so; such as updates an entire section (i.e. product-forms) including it’s blocks when something changes by using product.selected_variant in custom-liquid to reference that variants metafield .
Advanced - For vintage themes reference either the ‘Show Skus’ or ‘Show remaining inventory’ customizations to build such features.
https://help.shopify.com/en/manual/online-store/themes/themes-by-shopify/vintage-themes/customizing-vintage-themes/show-sku
https://help.shopify.com/en/manual/online-store/themes/themes-by-shopify/vintage-themes/customizing-vintage-themes/show-remaining-quantity
Hi Jonathan,
Displaying the active variant metafields on the product page is quite a tricky task. The thing is that Liquid can’t react to any changes on the product page dynamically, which means that you’ll have to add some JavaScript code to make it possible. Here’s the link to a solved thread dedicated to a similar task.