Created
March 16, 2012 21:14
-
-
Save carolineschnapp/2052746 to your computer and use it in GitHub Desktop.
Showing or hiding a back-order message
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_management != '' && variant.inventory_quantity < 0) { | |
| $('.backorder').show(); | |
| } | |
| else { | |
| $('.backorder').hide(); | |
| } | |
| $("input#add").removeClass("disabled").removeAttr("disabled"); | |
| $("h2#price span").html(Shopify.formatMoney(variant.price, "{{ shop.money_format }}")); | |
| if (variant.compare_at_price) { | |
| $("h2#price del").html(Shopify.formatMoney(variant.compare_at_price, "{{ shop.money_format }}")); | |
| } | |
| else { | |
| $("h2#price del").empty(); | |
| } | |
| } | |
| else { | |
| $('.backorder').hide(); | |
| $("input#add").addClass("disabled").attr("disabled", "disabled"); | |
| var message = variant ? "Sold Out" : "Unavailable"; | |
| $("h2#price span").text(message); | |
| $("h2#price del").empty(); | |
| } | |
| }; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There are like 3 situations here: is unavailable/sold out (1), is back-order (2) and is in stock (3).
The difference between (2) and (3) is ONLY the backorder message - for it to be shown or hidden.
Everything else is the same, that is, in both (2) and (3) we do NOT disable the add to cart button, we DO show the price, etc. It's business as usual, only difference is showing or not the backorder message.