• ondrej.krejc

    (@ondrejkrejc)


    Hi i have this code at /single-product/meta.php

    <?php
       $dimensions = $product->get_dimensions();
       if ( ! empty( $dimensions ) ) {
          echo '<div class="dimensions">Rozměry: ?.' . $product->get_width();
          echo ' h.' . $product->get_length();
          echo ' v.' . $product->get_height() . " " . get_option( 'woocommerce_dimension_unit' );
          echo '</div>';        
       }
    
    ?>

    But it works only for single product. If i have product with variations it’s blank.

    Also tried, this, but not work.

    global $product
    $variations = $product->get_available_variations();
    foreach ( $variations as $variable_array ){
        $variation = new WC_Product( $variable_array['variation_id'] );
        echo "The length is {$variation->length}.";
    }
  • The topic ‘Showing product dimension at product meta’ is closed to new replies.