title: How to hide unavailable product variants in Shopify?
body: <p>I'm trying to make only the available product variants visible in drop downs for products like <a href="https://mygraduationfilmshop1.myshopify.com/products/graduation-dvd-1" rel="nofollow">this one</a>. For example, say you choose 2012 in the first drop down, it would only show the available choices in the second. If you then chose Wed 25th July in the second, it would only show the available variants in the third. At the minute it shows all choices and states 'We don't offer the product in this combination' for an unavailable choice. </p>
  
  <p>So far, my <code>product.liquid</code> page has this code:</p>
  
  <pre><code>&lt;div class="col-7 product-description clearfix"&gt;
  &lt;h1&gt;{{ product.title }}&lt;/h1&gt;
  
  {{ product.description }}
      {% include 'addthis' %}
      &lt;br/&gt;&lt;br/&gt;
  
  {% if product.available  %} 
      {% if product.variants.size &gt; 1 %}
      &lt;!-- If the product only has MULTIPLE OPTIONS --&gt;
      &lt;form action="/cart/add" method="post" class="product-variants"&gt;     
          &lt;div id="options"&gt;
              &lt;select id="product-select" name='id'&gt;
                  {% for variant in product.variants %}
                      &lt;option value="{{ variant.id }}"&gt;{{ variant.title }}&lt;/option&gt;
                  {% endfor %}
              &lt;/select&gt;
              &lt;div class="select-wrapper"&gt;
                &lt;label for="region"&gt;DVD Region&lt;/label&gt;
                &lt;select id="color" required&gt;
                  &lt;option value="NTSC"&gt;NTSC&lt;/option&gt;
                  &lt;option value="PAL/SECAM" selected="selected"&gt;PAL/SECAM&lt;/option&gt;
                &lt;/select&gt;
              &lt;/div&gt;
              &lt;p&gt;&lt;a href="http://www.videouniversity.com/articles/world-wide-tv-standards/" target="_blank"&gt;Click Here&lt;/a&gt; find out more about your region.&lt;/p&gt;
  
          &lt;/div&gt; &lt;!-- options --&gt; 
  
          &lt;div class="price-field"&gt;&lt;/div&gt;
          &lt;input type="submit"  name="add" value="Add to cart" id="purchase" /&gt;
      &lt;/form&gt;
  
  {% else %}
      &lt;!-- If the product only has ONE variant --&gt;
      &lt;form action="/cart/add" method="post" class="product-variants"&gt;     
          &lt;div class="price-field"&gt; {{ product.price | money }}&lt;/div&gt;
          &lt;input type="submit"  name="add" value="Add to cart" id="purchase" /&gt;
          &lt;input  type="hidden" id="{{ variant.id }}" name="id" value="{{ product.variants[0].id }}" /&gt; &lt;!-- passes variant id --&gt;
      &lt;/form&gt;
  {% endif %}
  
  {% else %}
      &lt;p&gt;This product is not available&lt;/p&gt;
  {% endif %}  
  
  &lt;/div&gt;&lt;!-- .col-7 --&gt;
  
  &lt;div class="col-5 last product-thumbs"&gt;
  &lt;ul&gt;
  {% for image in product.images %}
      {% if forloop.first %}
          &lt;li class="featured-image" &gt;
              &lt;a class="zoom " href="{{ image | product_img_url: 'large' }}" title="{{ product.featured_image.alt | escape }}"&gt;
                  &lt;img  src="{{ image | product_img_url: 'large' }}" alt="{{ product.featured_image.alt | escape }}" /&gt;
              &lt;/a&gt;
          &lt;/li&gt;
          {% else %}
          &lt;li&gt;
              &lt;a class="zoom" href="{{ image | product_img_url: 'large' }}" title="{{ image.alt | esacpe }}"&gt;
                  &lt;img class="" src="{{ image | product_img_url: 'small' }}" alt="{{ image.alt | escape }}" /&gt;
              &lt;/a&gt;
          &lt;/li&gt;
      {% endif %}
   {% endfor %}
  &lt;/ul&gt;
  &lt;/div&gt;&lt;!-- .col-5 --&gt;
  
  &lt;script type="text/javascript"&gt;
  // &lt;![CDATA[  
  var selectCallback = function(variant, selector) {
    if (variant &amp;&amp; variant.available == true) {
      // selected a valid variant
      jQuery('#purchase').removeClass('disabled').removeAttr('disabled'); // remove unavailable class from add-to-cart button, and re-enable button
      jQuery('#purchase').fadeIn();
      jQuery('.price-field').html(Shopify.formatMoney(variant.price, "{{shop.money_with_currency_format}}"));  // update price field
    } else {
      // variant doesn't exist
      jQuery('#purchase').addClass('disabled').attr('disabled', 'disabled');      // set add-to-cart button to unavailable class and disable button
      jQuery('#purchase').fadeOut();
      var message = variant ? "Sold Out" : "We don't offer the product in this combination"; 
      jQuery('.price-field').text(message); // update price-field message
    }
  };
  
  
  // initialize multi selector for product      
  jQuery(document).ready(function() {
    new Shopify.OptionSelectors("product-select", { product: {{ product | json }}, onVariantSelected: selectCallback });
     {% assign found_one_in_stock = false %}
    {% for variant in product.variants %}
      {% if variant.available and found_one_in_stock == false %}
        {% assign found_one_in_stock = true %}
        {% for option in product.options %}
          jQuery('.single-option-selector:eq(' + {{ forloop.index0 }} + ')').val({{ variant.options[forloop.index0] | json }}).trigger('change');
        {% endfor %}
      {% endif %}
    {% endfor %}
    $('#options div').addClass("selector-wrapper");
    {% if product.options.size == 1 %}
      $(".selector-wrapper").append("&lt;label&gt;{{ product.options.first }}&lt;/label&gt;");
    {% endif %}
  });   
  // ]]&gt;  
  &lt;/script&gt;
  </code></pre>
  
  <p>Any help?</p>