Last active
August 29, 2015 13:57
-
-
Save msmithstubbs/9810727 to your computer and use it in GitHub Desktop.
Back In Stock Inline for for Symmetry theme
This file contains hidden or 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
| <script> | |
| /* Back In Stock app */ | |
| $(function() { | |
| function createNotification(e) { | |
| var $productContainer = $(e.target).closest('div[data-product-id], #main-product-detail'), | |
| productId = $(e.target).data('product-id'), | |
| email = $productContainer.find('[name=BIS_email]').val(), | |
| variantId; | |
| if ($productContainer.find('[name=id]').length > 0) { | |
| variantId = $productContainer.find('[name=id]').val(); | |
| } else { | |
| variantId = $(e.target).data('default-variant-id'); | |
| } | |
| $productContainer.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(); | |
| } | |
| } | |
| $productContainer.find('.BIS_response').text(message); | |
| }); | |
| } | |
| $('body').on('click', '.BIS_submit', createNotification); | |
| }); | |
| </script> |
This file contains hidden or 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
| <!-- Back In Stock app --> | |
| <form> | |
| <p> | |
| <input placeholder="Email address" type="email" name="BIS_email" id="BIS_email"> | |
| <button type="button" data-product-id="{{product.id}}" data-default-variant-id="{{product.variants.first.id}}" class="BIS_submit">Notify Me When Available</button> | |
| </p> | |
| <p class="BIS_response"></p> | |
| </form> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Installation instructions
snippets/product-detail.liquidand find the line This product is unavailable{% include 'bis-notify-me' with product %}product-detail.liquidlayouts/theme.liquid</body>add{% include 'bis-notify-me-js' %}theme.liquid