Created
December 9, 2013 17:43
-
-
Save fredryk/7876601 to your computer and use it in GitHub Desktop.
When products are out of stock, how do I indicate that shipping time will be longer for those? Will now work with multiple variants. :)
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) { | |
| if (variant.inventory_policy == 'continue' && variant.inventory_quantity <= '0'){ | |
| console.log("thingeroo"); | |
| jQuery('.notice').text('Test'); | |
| } | |
| else { | |
| jQuery('.notice').text(''); | |
| 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, "{{ shop.money_format }}") + " <del>" + Shopify.formatMoney(variant.compare_at_price, "{{ shop.money_format }}") + "</del>"); | |
| } else { | |
| jQuery('#price-preview').html(Shopify.formatMoney(variant.price, "{{ shop.money_format }}")); | |
| } | |
| } | |
| } 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); | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment