Created
January 14, 2019 06:13
-
-
Save mborodov/c8abb2045d7d4b5730ed0665ab39821e to your computer and use it in GitHub Desktop.
Pre-select first option for Magento 2 options swatcher
This file contains 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
if (this.options.jsonConfig.attributes.length > 0) { | |
var selectswatch = this.element.find('.' + this.options.classes.attributeClass + ' .' + this.options.classes.attributeOptionsWrapper); | |
$.each(selectswatch, function (index, item) { | |
var swatchOption = $(item).find('div.swatch-option').first(); | |
if (swatchOption.length && !$(item).find('div.swatch-option').hasClass('selected')) { | |
swatchOption.trigger('click'); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Need add this code to function _onGalleryLoaded.