Skip to content

Instantly share code, notes, and snippets.

@kellyvaughn
Last active May 16, 2018 10:57
Show Gist options
  • Select an option

  • Save kellyvaughn/dafea88c1469bb488c87e89623be20d6 to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown

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

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

@kellyvaughn

Copy link
Copy Markdown
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