I have some configurable products with a custom color swatches attribute. Lot of them have just one color options, so i 'd like to mark the option as selected in the product page. I added a custom js script to the product page but it works just in chrome console, not in the website. (Jquery is inthe required function, i don't know why stack's editor does not read it as code)
var number = $('.swatch-attribute .color').length;
if(number==1){
$('.swatch-attribute .color').click();
}
It does not work and the color option it is still not selected, how can i fix it?