'Display All WooCommerce Variation Information on Product Page

While this works fine as is, I need help in getting it to display all the different variation details that are available.

As of now, it displays the price. This is the full list of variables that are available:

'attributes'
'availability_html'
'backorders_allowed'
'dimensions'
'dimensions_html'
'display_price'
'display_regular_price'
'price'
'image'
'image_id'
'is_downloadable'
'is_in_stock'
'is_purchasable'
'is_sold_individually'
'is_virtual'
'max_qty'
'min_qty'
'price_html'
'sku'
'variation_description'
'variation_id'
'variation_is_active'
'variation_is_visible'
'weight'
'weight_html'

This is the code that I need help changing into displaying all of these as a table if at all possible.

add_action( 'woocommerce_after_add_to_cart_form', 'display_variation_info_in_product_summary' );
function display_variation_info_in_product_summary() {

   global $product;

            if ( ! $product->is_type( 'variable' ) ) return;

                    echo '<div class="var_info"></div>';
                       wc_enqueue_js( "
                          $(document).on('found_variation', 'form.cart', function( event, variation ) {
                             $('.var_info').html(variation.price_html); // need to show all options here
                      });
               " );
}


Solution 1:[1]

does this work? I'm using this to display a table of the variation options, with the price. It works with multiple attributes.

add_action( 'woocommerce_before_add_to_cart_form', 'display_variation_info_in_product_summary' );
function display_variation_info_in_product_summary() {
  global $product;

  if ( !$product->is_type( 'variable' ) ) return;

  $variations = $product->get_available_variations();

  echo '<div class="variation-prices"><table>';
  foreach($variations as $variation){
    $attributes = wc_get_formatted_variation($variation['attributes'],true, false);
    echo '<tr><td>' . $attributes . '</td><td>' . wc_price($variation['display_price']) . '</td></tr>';
  }
  echo '</table></div>';
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bensey