Skip to content

Instantly share code, notes, and snippets.

  • Save shopifypartners/f76c3cbd9851c79c9fb7c7e681980b22 to your computer and use it in GitHub Desktop.
Save shopifypartners/f76c3cbd9851c79c9fb7c7e681980b22 to your computer and use it in GitHub Desktop.
function attachOnVariantSelectListeners(product) {
$('.variant-selectors').on('change', 'select', function(event) {
var $element = $(event.target);
var name = $element.attr('name');
var value = $element.val();
product.options.filter(function(option) {
return option.name === name;
})[0].selected = value;
var selectedVariant = product.selectedVariant;
var selectedVariantImage = product.selectedVariantImage;
updateVariantImage(selectedVariantImage);
updateVariantTitle(selectedVariant);
updateVariantPrice(selectedVariant);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment