Skip to content

Instantly share code, notes, and snippets.

@kellyvaughn
Last active May 16, 2018 10:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kellyvaughn/dafea88c1469bb488c87e89623be20d6 to your computer and use it in GitHub Desktop.
Save kellyvaughn/dafea88c1469bb488c87e89623be20d6 to your computer and use it in GitHub Desktop.
Back in Stock
{% if product.tags contains "bis-hidden" %}
<p class="out-of-stock">{{ settings.out-of-stock-message }}</p>
{% else %}
<div class="product-reorder">
<h3>{{ settings.restock-notify-heading }}</h3>
<p>{{ settings.restock-notify-message }}</p>
<div class="restock-notify-form">
<input type="email" id="notify_email"{% if customer.email != blank %} value="{{ customer.email }}"{% endif %}>
<button id="notify_button">{{ settings.notify-me-button }}</button>
</div>
</div>
{% endif %}
<script>
var notificationCallback = function(data) {
var msg = '';
if (data.status == 'OK') {
msg = data.message; // just show the success message
} else { // it was an error
for (var k in data.errors) { // collect all the error messages into a string
msg += (k + " " + data.errors[k].join());
}
}
alert(msg);
}
$('#notify_button').click(function(e) {
e.preventDefault();
var email = $('#notify_email').val(),
productId = {{ product.id }}, // rendered by Liquid
variantId = {{ product.variants.first.id }}; // rendered by Liquid
BIS.create(email, variantId, productId).then(notificationCallback); // create the notification
})
</script>
@msmithstubbs
Copy link

Just need to include the product id as the third parameter:

BIS.create(email, variantId, productId).then(notificationCallback);

@kellyvaughn
Copy link
Author

Aha! Good catch. Forgot to update that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment