Skip to content

Instantly share code, notes, and snippets.

@msmithstubbs
Last active June 6, 2017 06:09
Show Gist options
  • Select an option

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

Select an option

Save msmithstubbs/4660146 to your computer and use it in GitHub Desktop.
Show a 'Notify me' button, and hide the 'Add' button.
<!-- Updating the product.liquid HTML to have a hidden Notify Me button -->
<!-- START BUY -->
<div id="buy" class="clear">
<h2 id="price"><span>$135.00</span></h2>
<input class="button" type="submit" id="add" value="Buy Now" />
<a href="#" id="notifyme">Notify when available</a>
</div>
<!-- END BUY -->
/* Then hide the notify me button by default */
#notifyme {
display: none;
}
// Update the selectCallback to show or hide the Add button and Notify Me as appropriate.
var selectCallback = function(variant, selector) {
if (variant && variant.available == true) {
$("input#add").show();
$('#notifyme').hide();
$("h2#price span").html(Shopify.formatMoney(variant.price, "${{amount}}"));
if (variant.compare_at_price) {
$("h2#price del").html(Shopify.formatMoney(variant.compare_at_price, "${{amount}}"));
} else {
$("h2#price del").empty();
}
} else {
$("input#add").hide();
$('#notifyme').show();
var message = variant ? "Sold Out" : "Unavailable";
$("h2#price span").text(message);
$("h2#price del").empty();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment