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/5943057 to your computer and use it in GitHub Desktop.

Select an option

Save msmithstubbs/5943057 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.
*
*/
if (variant && variant.available == true) {
if(variant.price < variant.compare_at_price){
$('.was_price', $product).html(Shopify.formatMoney(variant.compare_at_price, $('form', $product).data('money-format')))
} else {
$('.was_price', $product).text('')
}
$('.sold_out', $product).text('');
$('.current_price', $product).html(Shopify.formatMoney(variant.price, $('form', $product).data('money-format')))
$('#add-to-cart', $product).removeClass('disabled').removeAttr('disabled').val('Add to Cart');
$('#BIS_trigger').hide(); // added for Back In Stock
} else {
var message = variant ? "Sold Out" : "Out of Stock";
$('.was_price', $product).text('')
$('.current_price', $product).text('')
$('.sold_out', $product).text(message);
$('#add-to-cart', $product).addClass('disabled').attr('disabled', 'disabled').val(message);
$('#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