').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;
});
};
var product = {"id": 4503690444859,"title": "Watersports Sock (Unisex)","handle": "watersports-sock-unisex","price": 23000,"price_min": 23000,"price_max": 23000,"available": true,"price_varies": false,"compare_at_price": null,"compare_at_price_min": 0,"compare_at_price_max": 0,"compare_at_price_varies": false,"variants": [{"id": 31957687631931,"title": "s / blk","option1": "s","option2":"blk","option3":null,"sku": "","requires_shipping": true,"taxable": false,"featured_image":{"id": 14076168536123,"product_id": 4503690444859,"width": 2048,"height": 2048,"src": "\/\/snorkeling-gear.com\/cdn\/shop\/products\/P370.jpg?v=1580959730"},"available": true,"public_title": "s / blk","options": ["s","blk"],"price": 23000,"weight": 0,"compare_at_price": null,"inventory_quantity": 4,"inventory_management": "shopify","inventory_policy": "deny","barcode": ""},{"id": 31957687664699,"title": "l / blk","option1": "l","option2":"blk","option3":null,"sku": "","requires_shipping": true,"taxable": false,"featured_image":{"id": 14076168536123,"product_id": 4503690444859,"width": 2048,"height": 2048,"src": "\/\/snorkeling-gear.com\/cdn\/shop\/products\/P370.jpg?v=1580959730"},"available": true,"public_title": "l / blk","options": ["l","blk"],"price": 23000,"weight": 0,"compare_at_price": null,"inventory_quantity": 10,"inventory_management": "shopify","inventory_policy": "deny","barcode": ""},{"id": 31957687697467,"title": "xl / blk","option1": "xl","option2":"blk","option3":null,"sku": "","requires_shipping": true,"taxable": false,"featured_image":{"id": 14076168536123,"product_id": 4503690444859,"width": 2048,"height": 2048,"src": "\/\/snorkeling-gear.com\/cdn\/shop\/products\/P370.jpg?v=1580959730"},"available": true,"public_title": "xl / blk","options": ["xl","blk"],"price": 23000,"weight": 0,"compare_at_price": null,"inventory_quantity": 2,"inventory_management": "shopify","inventory_policy": "deny","barcode": ""},{"id": 31957687730235,"title": "2xl / blk","option1": "2xl","option2":"blk","option3":null,"sku": "","requires_shipping": true,"taxable": false,"featured_image":{"id": 14076168536123,"product_id": 4503690444859,"width": 2048,"height": 2048,"src": "\/\/snorkeling-gear.com\/cdn\/shop\/products\/P370.jpg?v=1580959730"},"available": true,"public_title": "2xl / blk","options": ["2xl","blk"],"price": 23000,"weight": 0,"compare_at_price": null,"inventory_quantity": 10,"inventory_management": "shopify","inventory_policy": "deny","barcode": ""}],"featured_image": "\/\/snorkeling-gear.com\/cdn\/shop\/products\/P370.jpg?v=1580959730","options": ["Size","Color"]};
var $addToCartForm = $('#callBackVariant form[action="/cart/add"]');
if (window.MutationObserver && $addToCartForm.length) {
if (typeof observer === 'object' && typeof observer.disconnect === 'function') {
observer.disconnect();
}
var config = { childList: true, subtree: true };
var observer = new MutationObserver(function() {
Shopify.linkOptionSelectors(product);
observer.disconnect();
});
observer.observe($addToCartForm[0], config);
}