title: Greying out out-of-stock product variations (WooCommerce)
body: <p>[EDIT: it actually works when adding the code in functions.php and omitting the changes in code WC files. Important: it only works when ONE attribute exists. However when there are 2 attributes (size &amp; color for instance) then it doesn't work because it's not about out-of-stock variations anymore but about variation combinations, and indeed WooCommerce is completely clueless in this common scenario. Note that there seems to be no available plugin currently to address this very obvious problem either. Great.]</p>
  
  <p>Since 2.0 WooCommerce either hides out-of-stock product variations (an obvious problem since clients have then no way to know about their existence) or displays them just as in-stock variations (also a problem because clients are then systematically disappointed to find out the variation is out-of-stock <em>after</em> clicking purchase). </p>
  
  <p><a href="https://github.com/woothemes/woocommerce/issues/5661" rel="nofollow">This thread</a> includes a solution to grey out the out-of-stock product variations:</p>
  
  <p>Presumably to be added to <code>functions.php</code>:</p>
  
  <pre><code>add_filter( 'woocommerce_variation_is_active', 'grey_out_variations_when_out_of_stock', 10, 3 );
  
  function grey_out_variations_when_out_of_stock( $grey_out, $variation_id, $id ) {
  
      $variation = get_product( $variation_id );
  
      if ( ! $variation-&gt;is_in_stock() )
          return false;
  
      return true;
  }
  </code></pre>
  
  <p>To be done in <code>plugins/woocommerce/includes/class-wc-product-variation.php</code>:</p>
  
  <p>Change:</p>
  
  <pre><code>return apply_filters( 'woocommerce_variation_is_active', true, $this-&gt;variation_id, $this-&gt;id );
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>return apply_filters( 'woocommerce_variation_is_active', true, $this );
  </code></pre>
  
  <p>Also change:</p>
  
  <pre><code>return apply_filters( 'woocommerce_variation_is_visible', $visible, $this-&gt;variation_id, $this-&gt;id );
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>return apply_filters( 'woocommerce_variation_is_visible', $visible, $this-&gt;variation_id, $this-&gt;id, $this );
  </code></pre>
  
  <p>Yet although it reportedly works, in my case the out-of-stock variations are displayed the same as the others and I also have a warning:</p>
  
  <pre><code>Warning: Missing argument 3 for grey_out_variations_when_out_of_stock() in ...\functions.php on line 600
  </code></pre>
  
  <p>What am I doing wrong? </p>