diff --git a/snippets/product-variant-picker.liquid b/snippets/product-variant-picker.liquid index ea93211..3ff92f7 100644 --- a/snippets/product-variant-picker.liquid +++ b/snippets/product-variant-picker.liquid @@ -200,6 +200,20 @@ } } }); + + // Set the initial value when the page loads + window.addEventListener('load', function() { + const selectedValue = selectElement.value; + selectedButton.innerText = selectedValue; + + document.querySelectorAll('.shx-custom-dropdown-content div').forEach(div => { + if (div.getAttribute('data-value') === selectedValue) { + div.classList.add('shx-custom-selected-variant'); + } else { + div.classList.remove('shx-custom-selected-variant'); + } + }); + }); {%- if picker_type == 'swatch' -%}