Created
August 29, 2013 07:42
-
-
Save msmithstubbs/6375212 to your computer and use it in GitHub Desktop.
andrebadi.myshopify.com selectCallback
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
| // IMPORTANT: Please backup your theme before making any changes. | |
| var selectCallback = function(variant, selector) { | |
| if (variant && variant.available) { | |
| jQuery('#add-to-cart').removeAttr('disabled').removeClass('disabled'); // remove unavailable class from add-to-cart button, and re-enable button | |
| if(variant.price < variant.compare_at_price){ | |
| jQuery('#price-preview').html(Shopify.formatMoney(variant.price, "$ {{amount}}") + " <del>" + Shopify.formatMoney(variant.compare_at_price, "$ {{amount}}") + "</del>"); | |
| } else { | |
| jQuery('#price-preview').html(Shopify.formatMoney(variant.price, "$ {{amount}}")); | |
| } | |
| jQuery('#BIS_trigger').hide(); // added for Back In Stock app | |
| } else { | |
| jQuery('#add-to-cart').addClass('disabled').attr('disabled', 'disabled'); // set add-to-cart button to unavailable class and disable button | |
| var message = variant ? "Sold Out" : "Unavailable"; | |
| jQuery('#price-preview').text(message); | |
| jQuery('#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