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!
Please let me know in the comments if everything went as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting.
Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!
Business Bloomer Founder
Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.
27 thoughts on “WooCommerce: Display Height, Length, Width @ Shop Page”
Thank you, this was just what I was looking for.
Hey there, is it possible to show dimensions in CM and Inches at the same time? So ideal enter in CM but convert and show in CM and Inches in the front end?
Hi Darren, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
This is great. How can we display attributes? For example, I have a “Size” attribute that I would like to display in the loop.
I guess small changes in your code would do the job?
Hi Ahmed, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Useful function. Thanks!
You’re welcome Slavi 🙂
It worked for me. Thank’s a lot!
Great, just what I needed to show the dimensions on the short description without using the tabs and it also fixed the direction problem with the units
Great to hear that Rubb 🙂
Oh please! Tell me how? I thought using ‘woocommerce_before_main_content’ instead of ‘woocommerce_after_shop_loop_item’ would do it, but no…
Oh wow, nevermind… I just found a very useful hook visual guide right here. That’s awesome Rodolfo!
How about variable products though?
That’s a little more complex. Also, which variation would you pick? Maybe it should be disabled for variable products 🙂
I found the answer to my own question. In woocommerce 3 get_dimensions() is deprecated. Besides throwing an error the old way is not empty anymore when there are no dimensions, they actually return N/A which means that displays. Hope this helps others. In your code example
reference for this is here
Excellent, thank you so much Mark!
You’re welcome Iggy!
Hi, I have been using $product->get_dimensions(); in my functions file for a long time. I turned on debug recently when working on something else on got this notice…
“Notice: WC_Product::get_dimensions was called with an argument that is deprecated since version 3.0! By default, get_dimensions has an argument set to true so that HTML is returned. This is to support the legacy version of the method. To get HTML dimensions, instead use wc_format_dimensions() function”
This works great for my shop but how would I apply it to only one specific category and not all products? For example if I only want to show dimensions for baths and not chemicals?
Hey Donna, thanks for your comment! Check this out, it should help: https://businessbloomer.com/woocommerce-conditional-logic-ultimate-php-guide/
Perfect!! Thank you so much!
The snippet works beautifully.I would like know how to do like if we click on an icon it would display the dimensions or hover on icon it would display the dimensions. instead of showing it directly. i guess it would add more style to the shop page as well.
Hey KAVIARASU, thanks for your comment! You can do that with some CSS styling, unfortunately this is custom work and I cannot provide a complementary solution here on the blog. Thanks a lot for your understanding! ~R