Goal: display and dynamically update a product variant title above the variant selection (“variant pills” = clickable buttons for each variant) in a Shopify Dawn 7.0 theme.
Initial setup: Liquid code in main-product.liquid shows the selected or first available variant title in a span.
Guidance: Changes should be handled via the theme’s JavaScript. Either modify the variant selection logic or listen for change events to update the span text.
Theme-specific solution (Dawn 7.0): Use global.js and add code in the onVariantChange() function to update the span when a new variant is selected.
Implementation provided: Retrieve the currently checked variant value and write it to the span element.
Code: var checkedValue = document.querySelector(‘.product-form__input input:checked’).value; document.getElementById(‘size-value’).innerHTML = checkedValue;
Outcome: Resolved. The span now updates on variant selection via onVariantChange(). No open questions noted.