title: Woocommerce - Displaying variations inside the loop
body: <pre><code>&lt;?php
  
      switch ( $product-&gt;product_type ) {
          case "variable" :
              $link   = apply_filters( 'variable_add_to_cart_url', get_permalink( $product-&gt;id ) );
              $label  = apply_filters( 'variable_add_to_cart_text', __('Select options', 'woocommerce') );
          break;
          case "grouped" :
              $link   = apply_filters( 'grouped_add_to_cart_url', get_permalink( $product-&gt;id ) );
              $label  = apply_filters( 'grouped_add_to_cart_text', __('View options', 'woocommerce') );
          break;
          case "external" :
              $link   = apply_filters( 'external_add_to_cart_url', get_permalink( $product-&gt;id ) );
              $label  = apply_filters( 'external_add_to_cart_text', __('Read More', 'woocommerce') );
          break;
          default :
              $link   = apply_filters( 'add_to_cart_url', esc_url( $product-&gt;add_to_cart_url() ) );
              $label  = apply_filters( 'add_to_cart_text', __('Add to cart', 'woocommerce') );
          break;
      }
  
      printf('&lt;a href="%s" rel="nofollow" data-product_id="%s" class="add_to_cart_button button product_type_%s"&gt;%s&lt;/a&gt;', $link, $product-&gt;id, $product-&gt;product_type, $label);
  
  ?&gt;
  </code></pre>
  
  <p>I'm trying to get variations to display inside the loop so customers can add variable products to their cart from the shop page (please see screenshot below)...</p>
  
  <p><a href="http://cl.ly/image/42401k0X0X2I" rel="nofollow">http://cl.ly/image/42401k0X0X2I</a></p>
  
  <p>I know I need to include the function- </p>
  
  <pre><code>get_available_variations();
  </code></pre>
  
  <p>And i'm pretty sure this already returns an array, it's just putting that array into a select dropdown + listing the variations (S,M,L,XL) and having a link to add that variation to the basket.</p>
  
  <p>Cheers!</p>