Created
November 18, 2011 20:16
-
-
Save carolineschnapp/1377624 to your computer and use it in GitHub Desktop.
Fix for On the Go theme
This file contains 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
<!-- BEFORE --> | |
var selectCallback = function(variant, selector) { | |
if (variant && variant.available == true) { | |
// selected a valid variant | |
jQuery('#add-to-cart').removeClass('disabled').removeAttr('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 { | |
// variant doesn't exist | |
jQuery('#add-to-cart').addClass('disabled').attr('disabled', 'disabled'); // set add-to-cart button to unavailable class and disable button | |
var message = variant ? "{{ settings.tr_sold_out }}" : "{{ settings.tr_unavailable }}"; | |
jQuery('#product .variants .price').text(message); // update price-field message | |
} | |
}; | |
<!-- FIX --> | |
var selectCallback = function(variant, selector) { | |
if (variant && variant.available == true) { | |
// selected a valid variant | |
jQuery('#add-to-cart').removeClass('disabled').removeAttr('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 }}")); | |
} | |
jQuery('#add-to-cart').val("{{ settings.tr_add_to_cart }}"); // update button label. | |
} else { | |
// variant doesn't exist | |
jQuery('#add-to-cart').addClass('disabled').attr('disabled', 'disabled'); // set add-to-cart button to unavailable class and disable button | |
var message = variant ? "{{ settings.tr_sold_out }}" : "{{ settings.tr_unavailable }}"; | |
jQuery('#add-to-cart').val(message); // update button label. | |
} | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment