Skip to content

Instantly share code, notes, and snippets.

@msmithstubbs
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

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

Select an option

Save msmithstubbs/0a8bc4f170dedb0da9e1 to your computer and use it in GitHub Desktop.
Back In Stock form for Shopify Simple theme
<div class="BIS_container">
<p>Be the first to know when this is available to order again.</p>
<input type="text" name="BIS_email" class="BIS_email" placeholder="email address">
<input type="button" class="btn BIS_button" value="Email when available">
<p class="BIS_response"> </p>
</div>
<script>
$(function() {
$('.BIS_container').on('click', '.BIS_button', function(e) {
var $container = $(e.delegateTarget),
email = $container.find('.BIS_email').val(),
variantId = $container.closest('form').find('[name=id]').val();
BISPopover.create(email, variantId).then(function(data) {
var message = '';
if (data.status == 'OK') {
message = data.message;
} else {
for (var k in data.errors) {
message += data.errors[k].join();
}
}
$container.find('.BIS_response').text(message);
});
});
});
</script>
/* Change Add to cart at line 57 from: */
<input type="submit" value="Add To Cart" id="add" class="btn add-to-cart" />
/* to: */
{% if product.available %}
<input type="submit" value="Add To Cart" id="add" class="btn add-to-cart" />
{% else %}
<h2>Sold out</h2>
{% include 'back-in-stock' %}
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment