Last active
August 29, 2015 14:11
-
-
Save kyledurand/364d437df5c0ecea5b22 to your computer and use it in GitHub Desktop.
Allow for featured image to be displayed by default in variant images core
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% assign featured_image = product.featured_image | default: product.featured_image %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//wrap switch image in function | |
$('.single-option-selector').change(function(){ | |
if (variant.featured_image) { | |
var newImage = variant.featured_image; | |
etc.. | |
} | |
}); | |
//add this below new optionSelectors | |
{% if product.variants.size > 1 %} | |
{% for option in product.options %} | |
$('.single-option-selector:eq({{ forloop.index0 }})') | |
.filter(function() { return $(this).find('option').size() > 1 }) | |
.prepend('<option value="">Choose ' + {{ product.options[forloop.index0] | json }} + '</option>') | |
.val('') | |
//hide this next line or it will interfere with callback code above | |
//.trigger('change'); | |
{% endfor %} | |
{% endif %} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Super Hacky. Not recommended.