Last active
May 16, 2018 10:57
-
-
Save kellyvaughn/dafea88c1469bb488c87e89623be20d6 to your computer and use it in GitHub Desktop.
Back in Stock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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> |
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
Just need to include the product id as the third parameter: