').val(option).html(option);
selector.append(newOption);
}
//console.log(availableOptionsJas);
jQuery('#callBackVariant .swatches-select[data-option-index="' + selectorIndex + '"] .basel-swatch').each(function() {
//console.log('sdffsdfds');
if (jQuery.inArray($(this).attr('data-value'), availableOptions) !== -1) {
$(this).removeClass('jas_unavailable')
}
else {
$(this).addClass('jas_unavailable')
}
});
jQuery('#callBackVariant .swatches-select[data-option-index="' + selectorIndex + '"] .basel-swatch').each(function() {
//console.log('sdffsdfds');
if (jQuery.inArray($(this).attr('data-value'), availableOptionsJas) !== -1) {
$(this).removeClass('jas_soldout')
}
else {
$(this).addClass('jas_soldout')
}
});
if (jQuery.inArray(initialValue, availableOptions) !== -1) {
selector.val(initialValue);
}
selector.trigger('change');
};
Shopify.linkOptionSelectors = function(product) {
// Building our mapping object.
for (var i=0; i 1) {
var key = variant.option1;
Shopify.optionsMap[key] = Shopify.optionsMap[key] || [];
Shopify.optionsMap[key].push(variant.option2);
Shopify.optionsMap[key] = Shopify.uniq(Shopify.optionsMap[key]);
}
// Gathering values for the 3rd drop-down.
if (product.options.length === 3) {
var key = variant.option1 + ' / ' + variant.option2;
Shopify.optionsMap[key] = Shopify.optionsMap[key] || [];
Shopify.optionsMap[key].push(variant.option3);
Shopify.optionsMap[key] = Shopify.uniq(Shopify.optionsMap[key]);
}
}
if (variant.available) {
// Gathering values for the 1st drop-down.
Shopify.optionsMapJas['root'] = Shopify.optionsMapJas['root'] || [];
Shopify.optionsMapJas['root'].push(variant.option1);
Shopify.optionsMapJas['root'] = Shopify.uniq(Shopify.optionsMapJas['root']);
// Gathering values for the 2nd drop-down.
if (product.options.length > 1) {
var key = variant.option1;
Shopify.optionsMapJas[key] = Shopify.optionsMapJas[key] || [];
Shopify.optionsMapJas[key].push(variant.option2);
Shopify.optionsMapJas[key] = Shopify.uniq(Shopify.optionsMapJas[key]);
}
// Gathering values for the 3rd drop-down.
if (product.options.length === 3) {
var key = variant.option1 + ' / ' + variant.option2;
Shopify.optionsMapJas[key] = Shopify.optionsMapJas[key] || [];
Shopify.optionsMapJas[key].push(variant.option3);
Shopify.optionsMapJas[key] = Shopify.uniq(Shopify.optionsMapJas[key]);
}
}
}
// Update options right away.
Shopify.updateOptionsInSelector(0);
if (product.options.length > 1) Shopify.updateOptionsInSelector(1);
if (product.options.length === 3) Shopify.updateOptionsInSelector(2);
// When there is an update in the first dropdown.
jQuery("#callBackVariant .single-option-selector:eq(0)").change(function() {
Shopify.updateOptionsInSelector(1);
if (product.options.length === 3) Shopify.updateOptionsInSelector(2);
return true;
});
// When there is an update in the second dropdown.
jQuery("#callBackVariant .single-option-selector:eq(1)").change(function() {
if (product.options.length === 3) Shopify.updateOptionsInSelector(2);
return true;
});
};