Skip to content
Advertisement

Display WooCommerce Product Dimensions via a Shortcode

I am creating a custom layout (using Elementor) for a product – what I need is to have the dimensions of a product to display in a custom tab I have created.

Is there a shortcode for product dimensions? (some of the products are variable too if that makes a difference)

I have managed to get some code to display the long description in a shortcode (see below) however I’m not advanced enough to know what to do to get it to display product dimensions (length, width, height – ideally each one on a separate line)

Here is the long description code i found that works…

JavaScript

Does anyone can give me some help to display product dimensions via a shortcode?

Advertisement

Answer

You can use the following simple code snippet, to display product dimensions via a shortcode:

JavaScript

Code goes in functions.php file of the active child theme (or active theme). it should works.

USAGE:

  • On WooCommerce product single page: [product_dimensions]
  • Anywhere with a defined Id (for example product Id 35): [product_dimensions id="35"]
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement