Skip to content

Instantly share code, notes, and snippets.

@msmithstubbs
Created October 8, 2014 09:59
Show Gist options
  • Select an option

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

Select an option

Save msmithstubbs/e7f279a5d5c319217153 to your computer and use it in GitHub Desktop.
Back In Stock inline page form
<div class="soldOut">
<h3>Email when available</h3>
<p>
<input type="text" name="BIS_email" class="BIS_email" placeholder="Enter email">
<button type="button" class="BIS_submit">GO</button>
</p>
<p class="BIS_response"></p>
<script>
/* Back In Stock app */
$(function() {
function createNotification(e) {
e.preventDefault();
var $container = $(e.target).closest('div'),
productId = BISPopover.product.id,
variantId = BISPopover.product.vid,
email = $container.find('[name=BIS_email]').val();
$container.find('.BIS_response').text('');
BISPopover.create(email, variantId, productId).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);
});
}
$('.BIS_submit').click(createNotification);
});
</script>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment