${function() {
let variantImageShowed = false;
const currentProduct = data.product;
return (currentProduct.options || []).map((option, index) => {
const optionName = option.name || '';
const optionId = option.id || '';
const position = `option${index + 1}`;
const productOptions = currentProduct.options || [];
const hasSizeOption = productOptions.some(({name = ''}) =>
name.toLowerCase().includes('size')
);
const hasNoSizeOption = productOptions.some(({name = ''}) =>
!name.toLowerCase().includes('size')
);
if(hasSizeOption && hasNoSizeOption) {
productOptions
.filter(({name = ''}) => name.toLowerCase().includes('size'))
.forEach(({name}) => data.selectedValues[name] = '');
}
let isThumbImage = false;
if (currentProduct.need_variant_image && !variantImageShowed) {
const variantNames = ["color"] || [];
for (let i = 0, len = variantNames.length; i < len; i++) {
const name = variantNames[i].toLowerCase();
if (name === optionName.toLowerCase()) {
isThumbImage = true;
variantImageShowed = true;
}
}
}
const variantType = "button";
const thumbStyle = "image_with_text";
return `