title: woocommerce shop product variations
body: <p>I would like to show all products and their variations on the Wp/Woocommerce /shop/ page. (/woocommerce/archive-product.php). The process I'm describing below is my attempt at getting this to work. Alternatives are welcome.</p>
  
  <p><strong><em>What is the norm:</strong> Product A and Product B show on the site. Product A has 'ad to cart' button. Product B has 'Select Options' button.</em></p>
  
  <p><strong><em>What I'm after</strong>: Product A is a 'simple' product and shows on the shop page
  Product B is a 'variable' product and has 2 combinations (Black/Blue). An Add to cart button adds this variation to the cart</em></p>
  
  <p>I would like to show 3 products on the shop page equaling 1* product A and 2* product B.</p>
  
  <p>So far I've pulled out if the product is variable some basic details about this product variation but I cannot seem to find the thumbnail? </p>
  
  <pre><code>$postId = get_the_ID();
  $args = array(
      'post_type'     =&gt; 'product_variation',
      'post_status'   =&gt; array( 'private', 'publish' ),
      'numberposts'   =&gt; -1,
      'orderby'       =&gt; 'menu_order',
      'order'         =&gt; 'asc',
      'post_parent'   =&gt; $postId
  );
  $variations = get_posts( $args );
  //var_dump($variations);
  
  //$p = get_post_meta($postId, '_product_attributes', true);  // return pa_flavor
  //var_dump($p);
  
  if(!empty($variations)) {
      foreach ($variations as $variation) {
  
          $vari = new WC_Product_Variation($variation-&gt;ID);
          $availableAttr = $vari-&gt;get_attribute('Flavour');
          $flavour = get_post_meta($variation-&gt;ID, 'attribute_pa_flavour', true);
  </code></pre>
  
  <p>Therefore, I can get the attribute for 'flavor' and am looking for the thumbnail that is defined for each variation...? Any help/pointers to where this could be are appreciated.</p>
  
  <p>Also [ probably my lack of understanding of Wordpress ] I cannot seem to pass/access variables in wc_get_template(). This is probably a secondary question but still related to the fundamental issue of displaying both single and variation products on one page.</p>
  
  <pre><code>remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
  add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price_variation', 10 );
  
  if ( ! function_exists( 'woocommerce_template_loop_price_variation' ) ) {
      function woocommerce_template_loop_price_variation($prodVar=array()) {
  
          if(empty($prodVar) || $prodVar['product_type'] == 'simple') {
              wc_get_template( 'loop/price.php' );
          }  else {
              wc_get_template( 'loop/price-variation.php' , $prodVar );
          }
      }
  }
  </code></pre>
  
  <p>And in /price-variation.php (copy of price.php woocommerce base)</p>
  
  <pre><code>global $product;
  var_dump($prodVar);  // PRODUCED NOTICE to undefined variable??? 
  &lt;?php if ( $price_html = $product-&gt;get_price_html() ) : ?&gt;
      &lt;span class="price"&gt;&lt;?php echo $price_html; ?&gt;&lt;/span&gt;
  &lt;?php endif; ?&gt;
  </code></pre>
  
  <p><em>I don't want it global...? or is this the only way?</em></p>
  
  <p>Any help or recommendations appreciated.</p>