// was " + Shopify.formatMoney(variant.compare_at_price, "€{{amount}}") + "");
} else {
jQuery('#price-preview').html(Shopify.formatMoney(variant.price, "€{{amount}}"));
}
} else {
// variant doesn't exist
jQuery('#add-to-cart').addClass('disabled').attr('disabled', 'disabled'); // set add-to-cart button to unavailable class and disable button
var message = variant ? "Sold Out" : "Unavailable";
jQuery('#product .variants .price').text(message); // update price-field message
}
};
function remove(s, t) {
/*
** Remove all occurrences of a token in a string
** s string to be processed
** t token to be removed
** returns new string
*/
i = s.indexOf(t);
r = "";
if (i == -1) return s;
r += s.substring(0,i) + remove(s.substring(i + t.length), t);
return r;
}
// initialize multi selector for product
jQuery(function() {
if(jQuery.cookie("viewed-products") != null){ // if cookie exists...
var products = jQuery.cookie("viewed-products");
var productHandles = products.split(" ");
var matches = 0;
var limit = 4;
for(var i = (productHandles.length - 1); i >= 0; i--) {
if(productHandles[i] != "notizbuch" && productHandles[i] != "" && (matches < limit)){
Shopify.getProduct(productHandles[i]);
matches++;
}
}
if(products.indexOf("notizbuch") == -1){ // add current product to list if it isn't already there
products += " notizbuch";
jQuery.cookie("viewed-products", products, {path: "/"});
} else { // if it is already there, push it to the end of the string
var newstring = remove(products, 'notizbuch');
newstring += " notizbuch";
jQuery.cookie("viewed-products", newstring.replace(/ /g,' '), {path: "/"});
}
} else { // create cookie if it doesn't already exist
jQuery.cookie("viewed-products", "notizbuch", {path: "/"});
}
});
// ]]>