Home » WooCommerce: Display Height, Length, Width @ Shop Page

WooCommerce: Display Height, Length, Width @ Shop Page

by Tutor Aspire

Another interesting snippet that could come very handy. How do we show the product dimensions (height, width, length) in the shop / category / tag / loop pages? This could be a handy trick for shops that calculate shipping rates based on volume, or when the volume is a vital piece of data customers need to know before proceeding further. Either way, enjoy!

WooCommerce: show product height, width, length @ loop

PHP Snippet: Show Product Height, Length, Width @ WooCommerce Shop Page

/**
 * @snippet       Display Product Height, Length, Width @ Shop Page - WooCommerce
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    WooCommerce 3.9
 * @donate $9     https://tutoraspire.com
 */
 
add_action( 'woocommerce_after_shop_loop_item', 'tutoraspire_show_product_dimensions_loop', 20 );
 
function tutoraspire_show_product_dimensions_loop() {
   global $product;
   $dimensions = $product->get_dimensions();
   if ( ! empty( $dimensions ) ) {
      echo '
Height: ' . $product->get_height() . get_option( 'woocommerce_dimension_unit' ); echo '
Width: ' . $product->get_width() . get_option( 'woocommerce_dimension_unit' ); echo '
Length: ' . $product->get_length() . get_option( 'woocommerce_dimension_unit' ); echo '
'; } }

You may also like