Skip to content

Instantly share code, notes, and snippets.

@msmithstubbs
Last active December 19, 2015 10:49
Show Gist options
  • Select an option

  • Save msmithstubbs/5943012 to your computer and use it in GitHub Desktop.

Select an option

Save msmithstubbs/5943012 to your computer and use it in GitHub Desktop.
/*
* Example code only. This code has not been tested on a live site.
* IMPORTANT: Backup your theme before making any modifications.
*
*/
var selectCallback = function(variant, selector) {
if (variant && variant.available == true) {
jQuery('#add-to-cart').removeAttr('disabled'); // remove unavailable class from add-to-cart button, and re-enable button
if(variant.price < variant.compare_at_price){
jQuery('#price-preview').html(Shopify.formatMoney(variant.price, "") + " <del>" + Shopify.formatMoney(variant.compare_at_price, "") + "</del>");
} else {
jQuery('#price-preview').html(Shopify.formatMoney(variant.price, ""));
}
jQuery('#BIS_trigger').hide(); // added for Back In Stock
} else { // variant does not exist
jQuery('#add-to-cart').attr('disabled', 'disabled'); // set add-to-cart button to unavailable class and disable button
var message = variant ? "Sold Out" : "Unavailable";
jQuery('#price-preview').text(message);
jQuery('#BIS_trigger').show(); // added for Back In Stock
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment