Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sarachisholm/7bc9d717feff9a371931c3ade576a179 to your computer and use it in GitHub Desktop.
Save sarachisholm/7bc9d717feff9a371931c3ade576a179 to your computer and use it in GitHub Desktop.
var variantSelectors = generateSelectors(product);
$('.variant-selectors').html(variantSelectors);
function generateSelectors(product) {
var elements = product.options.map(function(option) {
return '<select name="' + option.name + '">' + option.values.map(function(value) {
return '<option value="' + value + '">' + value + '</option>';
}) + '</select>';
});
return elements;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment