In stock");
if (variant.inventory_management) {
if(variantsInventory[variant.id][0] <= 0){
if(variantsInventory[variant.id][1] == 'continue'){
$preOder.html('
Sorry, this is out of stock
');
$addToCart.addClass('is-preorder').prop('disabled', false);
}else{
$addToCart.addClass('disabled is-soldout').prop('disabled', true);
}
}else{
$addToCart.removeClass('disabled is-soldout').prop('disabled', false);
}
}
if($firstOption.length > 0){
firstOptionPostion = $firstOption.data('option');
firstOptionValue = variant[firstOptionPostion];
optionUnavailable(null, firstOptionValue);
}
} else {
jQuery('.stock-availablity').empty().html("
Sold out");
$addToCart.addClass('disabled is-soldout').prop('disabled', true);
}
var checkOptionSelected = 0;
$selectOption.each(function(){
$(this).find('li').each(function(){
if($(this).hasClass('selected')){
checkOptionSelected += 1;
}
});
});
if($selectOptionSize == checkOptionSelected){
if (variant.compare_at_price > variant.price) {
$productPrice.html('
'+ Shopify.formatMoney(variant.compare_at_price, "£{{amount}}") +''+ Shopify.formatMoney(variant.price, "£{{amount}}") +'');
} else {
$productPrice.html('
'+ Shopify.formatMoney(variant.price, "£{{amount}}") + '' );
}
}else{
$addToCart.addClass('disabled').prop('disabled', true);
}
} else {
jQuery('.stock-availablity').empty().html("Unavailable");
$productForm.addClass('disabled').prop('disabled', true);
}
};
selectVariant = function() {
$elementSelectOption.on('click', function(e){
e.preventDefault();
var $this = $(this), $thisValue, $thisSelectOption, $thisOptionSelector, $thisOptionPosition, $thisOptionIndex, $option, $optionValue;
if($this.hasClass('selected') || $this.hasClass('out-of-stock') || $this.hasClass('unavailable')){
return;
}
$thisValue = $this.data('value');
$thisSelectOption = $this.parents(settings.selectOption).eq(0);
$thisOptionSelector = $($thisSelectOption.data('select-option'));
$thisOptionIndex = $thisSelectOption.index() + 1;
if($firstOption && $firstOption.find('li.selected').data('value') != undefined){
firstOptionValue = $firstOption.find('li.selected').data('value');
}
if($secondOption && $secondOption.find('li.selected').data('value') != undefined){
secondOptionValue = $secondOption.find('li.selected').data('value');
}
if($thirdOption && $thirdOption.find('li.selected').data('value') != undefined){
thirdOptionValue = $thirdOption.find('li.selected').data('value');
}
switch($thisOptionIndex) {
case 1:
firstOptionValue = $thisValue;
$elementSelectOption.removeClass('selected out-of-stock unavailable');
break;
case 2:
secondOptionValue = $thisValue;
break;
case 3:
thirdOptionValue = $thisValue;
break;
}
$this.addClass('selected');
$thisSelectOption.find('li').not($this).removeClass('selected');
$thisOptionSelector.val($thisValue).change();
/* custom */
$this.parents('.select-option').eq(0).find('.value').html($thisValue);
//$this.parents('.select-option').eq(0).toggleClass('active');
optionUnavailable($this, firstOptionValue, secondOptionValue, thirdOptionValue);
});
}
optionUnavailable = function($this, firstOptionValue, secondOptionValue, thirdOptionValue) {
var $dataFirstOptionValue, $dataSecondOptionValue, $dataThirdOptionValue, $dataInventoryQuantity, $dataVariantID, $optionOutOfStock, $thisSelectOption, $thisOptionIndex;
if($this != null){
$thisSelectOption = $this.parents(settings.selectOption).eq(0);
$thisOptionIndex = $thisSelectOption.index() + 1;
}
//First Option
if($firstOption.length > 0){
firstOptionPostion = $firstOption.data('option');
}
//Second Option
if($secondOption.length > 0){
secondOptionPostion = $secondOption.data('option');
}
//Third Option
if($thirdOption.length > 0){
thirdOptionPostion = $thirdOption.data('option');
}
//Out of Stock
if($firstOption.length > 0){
if(firstOptionValue != null){
if($thisOptionIndex == 1){
$elementSelectOption.removeClass('out-of-stock unavailable');
}
$firstOption.find('li[data-value="' + firstOptionValue + '"]').addClass('selected');
// One Option
if($secondOption.length == 0 && $thirdOption.length == 0){
$firstOption.find('li').removeClass('out-of-stock unavailable');
$productOptions.find('option').each(function(){
$dataFirstOptionValue = $(this).data(firstOptionPostion);
$dataInventoryQuantity = parseInt($(this).data('inventory_quantity'));
if($dataInventoryQuantity < 1){
$optionOutOfStock = $dataFirstOptionValue;
$firstOption.find('li').each(function() {
if($(this).data('value') == $optionOutOfStock){
$(this).addClass('out-of-stock');
}
});
}
});
checkOptionOutOfStock($firstOption, firstOptionPostion, firstOptionValue, firstOptionPostion);
}
if($thirdOption.length == 0){
// Two Options
if($secondOption.length > 0){
var $secondOptionValues = [], $secondOptionAvailableValues = [], $secondOptionUnavailableValues = [];
$secondOption.find('li').each(function(){
$secondOptionValues.push($(this).data('value'));
});
$productOptions.find('option').each(function(){
$dataFirstOptionValue = $(this).data(firstOptionPostion);
$dataSecondOptionValue = $(this).data(secondOptionPostion);
$dataInventoryQuantity = parseInt($(this).data('inventory_quantity'));
if($dataFirstOptionValue == firstOptionValue){
$secondOptionAvailableValues.push($dataSecondOptionValue);
if($dataInventoryQuantity < 1){
$optionOutOfStock = $dataSecondOptionValue;
$secondOption.find('li').each(function() {
if($(this).data('value') == $optionOutOfStock){
$(this).addClass('out-of-stock');
}
});
}
}
});
checkOptionOutOfStock($secondOption, secondOptionPostion, firstOptionValue, firstOptionPostion);
$secondOptionUnavailableValues = array_diff($secondOptionValues,$secondOptionAvailableValues);
if($secondOptionUnavailableValues.length > 0){
$secondOptionUnavailableValues.forEach(function(unavailableValue,index){
$secondOption.find('li').each(function() {
if($(this).data('value') == unavailableValue){
$(this).addClass('unavailable');
}
});
});
}
}
}else{
// Three Options
//Select Second Option
if(secondOptionValue != null){
var $thirdOptionValues = [], $thirdOptionAvailableValues = [], $thirdOptionUnavailableValues = [];
$thirdOption.find('li').removeClass('out-of-stock unavailable').each(function(){
$thirdOptionValues.push($(this).data('value'));
});
$productOptions.find('option').each(function(){
$dataFirstOptionValue = $(this).data(firstOptionPostion);
$dataSecondOptionValue = $(this).data(secondOptionPostion);
$dataThirdOptionValue = $(this).data(thirdOptionPostion);
$dataInventoryQuantity = parseInt($(this).data('inventory_quantity'));
if($dataFirstOptionValue == firstOptionValue && $dataSecondOptionValue == secondOptionValue){
$thirdOptionAvailableValues.push($dataThirdOptionValue);
if($dataInventoryQuantity < 1){
$optionOutOfStock = $dataThirdOptionValue;
$thirdOption.find('li').each(function() {
if($(this).data('value') == $optionOutOfStock){
$(this).addClass('out-of-stock');
}
});
}
}
});
checkOptionOutOfStock($thirdOption, thirdOptionPostion, firstOptionValue, firstOptionPostion, secondOptionValue, secondOptionPostion);
$thirdOptionUnavailableValues = array_diff($thirdOptionValues,$thirdOptionAvailableValues);
if($thirdOptionUnavailableValues.length > 0){
$thirdOptionUnavailableValues.forEach(function(unavailableValue,index){
$thirdOption.find('li').each(function() {
if($(this).data('value') == unavailableValue){
$(this).addClass('unavailable');
}
});
});
}
}
//Select Third Option
if(thirdOptionValue != null){
var $secondOptionValues = [], $secondOptionAvailableValues = [], $secondOptionUnavailableValues = [];
$secondOption.find('li').removeClass('out-of-stock unavailable').each(function(){
$secondOptionValues.push($(this).data('value'));
});
$productOptions.find('option').each(function(){
$dataFirstOptionValue = $(this).data(firstOptionPostion);
$dataSecondOptionValue = $(this).data(secondOptionPostion);
$dataThirdOptionValue = $(this).data(thirdOptionPostion);
$dataInventoryQuantity = parseInt($(this).data('inventory_quantity'));
if($dataFirstOptionValue == firstOptionValue && $dataThirdOptionValue == thirdOptionValue){
$secondOptionAvailableValues.push($dataSecondOptionValue);
if($dataInventoryQuantity < 1){
$optionOutOfStock = $dataSecondOptionValue;
$secondOption.find('li').each(function() {
if($(this).data('value') == $optionOutOfStock){
$(this).addClass('out-of-stock');
}
});
}
}
});
checkOptionOutOfStock($secondOption, secondOptionPostion, firstOptionValue, firstOptionPostion, thirdOptionValue, thirdOptionPostion);
$secondOptionUnavailableValues = array_diff($secondOptionValues,$secondOptionAvailableValues);
if($secondOptionUnavailableValues.length > 0){
$secondOptionUnavailableValues.forEach(function(unavailableValue,index){
$secondOption.find('li').each(function() {
if($(this).data('value') == unavailableValue){
$(this).addClass('unavailable');
}
});
});
}
}
}
}
}
};
checkOptionOutOfStock = function($option, optionPosition, selectFirstOptionValue, selectFirstOptionPosition, selectSecondOptionValue, selectSecondOptionPosition) {
var $dataInventoryQuantity, $optionOutOfStock;
$.getJSON('/cart.js', function (cart) {
jQuery.each(cart.items, function(index, item) {
productVariants.forEach(function(variant, index){
if (item.id == variant.id) {
if(selectFirstOptionValue != null && selectFirstOptionPosition != null){
if(selectSecondOptionValue == null && selectSecondOptionPosition == null){
if(variant[selectFirstOptionPosition] == selectFirstOptionValue){
$dataInventoryQuantity = variant.inventory_quantity - parseInt(item.quantity);
if($dataInventoryQuantity < 1){
$optionOutOfStock = variant[optionPosition];
$option.find('li').each(function() {
if($(this).data('value') == $optionOutOfStock){
$(this).removeClass('selected').addClass('out-of-stock');
}
});
}
}
}else{
if(variant[selectFirstOptionPosition] == selectFirstOptionValue && variant[selectSecondOptionPosition] == selectSecondOptionValue){
$dataInventoryQuantity = variant.inventory_quantity - parseInt(item.quantity);
if($dataInventoryQuantity < 1){
$optionOutOfStock = variant[optionPosition];
$option.find('li').each(function() {
if($(this).data('value') == $optionOutOfStock){
$(this).removeClass('selected').addClass('out-of-stock');
}
});
}
}
}
}
}
});
});
});
};
module = {
init: init
};
return module;
}(JunoProductAdd || {}, jQuery));
jQuery(document).ready(function () {
JunoProductAdd.init();
jQuery('.first-option').addClass('active');
jQuery('.first-option .label-value .value').html( jQuery('.first-option ul li:not(.out-of-stock)').first().data('value') );
var select_options = jQuery('#product-variants > div');
jQuery('.select-option li').click(function(){
select_options.removeClass('active');
_parent = jQuery(this).parent().parent();
_parent.addClass('active');
if(_parent.hasClass('colour-option')){
select_options.filter(':not(.colour-option)').find('.label-value .value').html('Please select');
select_options.find('ul').removeClass('active');
}
})
jQuery('.select-option .label-value').on('click', function(e){
e.preventDefault();
select_options.removeClass('active');
jQuery(this).next().toggleClass('active');
jQuery(this).parent().addClass('active');
});
/*
jQuery('.product-collapse .title').on('click', function(e){
e.preventDefault();
jQuery(this).toggleClass('active').next().slideToggle();
});
*/
var listContainers = jQuery('.specifications-content-container > div')
jQuery('.specifications-tab-menu a').click(function(e){
e.preventDefault();
listContainers.hide().filter(this.hash).show();
jQuery('.specifications-tab-menu li').removeClass('active');
jQuery(this).parent().addClass('active');
return false;
}).filter(':first').click();
if( jQuery('#product-variants').data('option-size') === 1 ){
if( !jQuery('#product-select-option-0').parent().find('label').length ){
jQuery('#product-select-option-0').parent().prepend('
')
}
}
});
// Specifications for snowtart only
$( document ).ready(function() {
$('.weight-bar').each(function(){
var weightClass = $(this).attr('class').replace('weight-bar', '').replace('weight-', '');
var weight = parseInt(weightClass);
for (let i = 1; i <= weight ; i++) {
$(this).find('.bar div:nth-child(' + i + ')').addClass('active')
}
});
});
// Specifications for snowtart only end
$(window).load(function() {
jQuery('.jump-to').on('click', function(e){
e.preventDefault();
var target = jQuery(this).data('href');
target = jQuery(target);
if (target.length) {
jQuery('html,body').animate({
scrollTop: ( target.offset().top - 140 )
}, 1000);
return false;
}
});
});