Created
October 8, 2014 09:59
-
-
Save msmithstubbs/e7f279a5d5c319217153 to your computer and use it in GitHub Desktop.
Back In Stock inline page form
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
| <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