title: Adding an "out-of-stock" class to variations shown as swatches - WooCommerce
body: <p>I'm trying to figure out of way of adding an "out-of-stock" class to WooCommerce variations shown as swatches when their stock level is at 0. </p>
  
  <p>I've found multiple ways of "greying out" out of stock variations when they are displayed in the standard WooCommerce drop down list - code shown below:</p>
  
  <pre><code>add_filter( 'woocommerce_variation_is_active', 'grey_out_variations_when_out_of_stock', 10, 2 );
  function grey_out_variations_when_out_of_stock( $grey_out, $variation ) {
  
  if ( ! $variation-&gt;is_in_stock() )
      return false;
      return true;
  }
  </code></pre>
  
  <p>However, this does not work when using a plugin to show my variations as swatches.</p>
  
  <p>I currently have a size attribute, and have used a plugin to shown each size as a separate box that can be selected. Similar to what is shown in this thread: <a href="https://stackoverflow.com/questions/45117773/woocommerce-variation-swatches-plugin-cross-out-not-matching-attributes">Click Here</a></p>
  
  <p>Is there some PHP, or JS that i could use to add a new stock to out of stock variations, which will then allow me to alter the CSS. Showing them as a red box, with a cross through it for example. </p>
  
  <p>During my search so far, i have come up empty handed, so any help would be appreciated. </p>