Skip to content

Instantly share code, notes, and snippets.

@msmithstubbs
Created July 19, 2013 16:51
Show Gist options
  • Select an option

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

Select an option

Save msmithstubbs/6040650 to your computer and use it in GitHub Desktop.
// Example code only
// This hasn't been tested on a real site. Please backup your theme before making any changes.
var selectCallback = function(variant, selector) {
if (variant && variant.available) {
jQuery('#add-to-cart').removeAttr('disabled').removeClass('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, "${{amount}}") + " <del>" + Shopify.formatMoney(variant.compare_at_price, "${{amount}}") + "</del>");
} else {
jQuery('#price-preview').html(Shopify.formatMoney(variant.price, "${{amount}}"));
}
} else {
jQuery('#add-to-cart').addClass('disabled').attr('disabled', 'disabled'); // set add-to-cart button to unavailable class and disable button
var message = variant ? '<input type="button" id="BIS_trigger" class="btn" value="Email me when in stock">' : "Unavailable";
jQuery('#price-preview').html(message);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment