Last active
December 15, 2015 18:59
-
-
Save msmithstubbs/5308518 to your computer and use it in GitHub Desktop.
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
| var selectCallback = function(variant, selector) { | |
| if (variant && variant.available == true) { | |
| // selected a valid variant | |
| $('#productinfo #detail #purchase').removeClass('disabled').removeAttr('disabled'); // remove unavailable class from add-to-cart button, and re-enable button | |
| var newHtml = Shopify.formatMoney(variant.price, ""); | |
| if(variant.compare_at_price > variant.price) { | |
| newHtml += '<div class="was-price">was ' + Shopify.formatMoney(variant.compare_at_price, "") + '</div>'; | |
| } | |
| $('#price-field').html(newHtml); // update price field | |
| // added for Back In Stock app | |
| if (variant.inventory_quantity == 0) { // some products are out of stock, but still available | |
| $('#BIS_trigger').show(); | |
| } else { | |
| $('#BIS_trigger').hide(); | |
| } | |
| } else { | |
| // variant doesn't exist | |
| $('#productinfo #detail #purchase').addClass('disabled').attr('disabled', 'disabled'); // set add-to-cart button to unavailable class and disable button | |
| var message = variant ? "This Size is Sold Out" : "Unavailable"; | |
| $('#price-field').text(message); // update price-field message | |
| $('#BIS_trigger').show(); // added for Back In Stock app | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment