carolineschnapp
11/18/2011 - 8:16 PM

Fix for On the Go theme

Fix for On the Go theme

<!-- 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.
  }
};