dropdown for product variant picker

main
alexanderroese 2024-07-13 18:06:38 +02:00
parent f9c9287ceb
commit baedde8a14
1 changed files with 14 additions and 0 deletions

View File

@ -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');
}
});
});
</script>
{%- if picker_type == 'swatch' -%}