Last active
June 6, 2017 06:09
-
-
Save msmithstubbs/4660146 to your computer and use it in GitHub Desktop.
Show a 'Notify me' button, and hide the 'Add' button.
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
| <!-- Updating the product.liquid HTML to have a hidden Notify Me button --> | |
| <!-- START BUY --> | |
| <div id="buy" class="clear"> | |
| <h2 id="price"><span>$135.00</span></h2> | |
| <input class="button" type="submit" id="add" value="Buy Now" /> | |
| <a href="#" id="notifyme">Notify when available</a> | |
| </div> | |
| <!-- END BUY --> |
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
| /* Then hide the notify me button by default */ | |
| #notifyme { | |
| display: none; | |
| } |
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
| // Update the selectCallback to show or hide the Add button and Notify Me as appropriate. | |
| var selectCallback = function(variant, selector) { | |
| if (variant && variant.available == true) { | |
| $("input#add").show(); | |
| $('#notifyme').hide(); | |
| $("h2#price span").html(Shopify.formatMoney(variant.price, "${{amount}}")); | |
| if (variant.compare_at_price) { | |
| $("h2#price del").html(Shopify.formatMoney(variant.compare_at_price, "${{amount}}")); | |
| } else { | |
| $("h2#price del").empty(); | |
| } | |
| } else { | |
| $("input#add").hide(); | |
| $('#notifyme').show(); | |
| var message = variant ? "Sold Out" : "Unavailable"; | |
| $("h2#price span").text(message); | |
| $("h2#price del").empty(); | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment