Display Height, Length, Width on Shop Page

Another intriguing Snippet that could be very useful. In the shop / category / tag / loop pages, how do we display product dimensions (height, breadth, and length)? This could be a useful trick for stores that calculate shipping charges depending on volume, or where volume is a crucial piece of information that shoppers must know before advancing.

Some Related Posts:-

See also  Pure CSS Vertical Page Slider

You can add the following Snippet on your Functions.php.

add_action( 'woocommerce_after_shop_loop_item', 'codeithub_show_product_dimensions_loop', 20 );
  
function codeithub_show_product_dimensions_loop() {
   global $product;
   $dimensions = $product->get_dimensions();
   if ( ! empty( $dimensions ) ) {
      echo '<div class="dimensions"><b>Height:</b> ' . $product->get_height() . get_option( 'woocommerce_dimension_unit' );
      echo '<br><b>Width:</b> ' . $product->get_width() . get_option( 'woocommerce_dimension_unit' );
      echo '<br><b>Length:</b> ' . $product->get_length() . get_option( 'woocommerce_dimension_unit' );
      echo '</div>';        
   }
}
Display Height, Length, Width

Leave a Reply

Your email address will not be published. Required fields are marked *