Have Woocommerce setup with a range of variable products. In the variable tab I’ve setup a unique price, image, description, weight & dimensions for each item.
All variable data displays as expected on the front-end except the dimensions & weight.
Despite hours of searching, I cannot find any documentation, tutorials, hints on how to hook into it.
Have Woocommerce templates setup and know that I will need to hook into the do_action( 'woocommerce_single_variation' );
in variable.php.
Anyone know how to get each variable’s dimensions & weight to display beneath the variable description?
If you have the variation ID, you can use it to create a
new WC_Product()
. This object will then have properties available on it for the$length
,$width
, and$height
. See the docs here (at the bottom under “Magic Properties”).To get the variations for a given product, you can use the
global $product
and then theget_available_variations()
function.If you want to display additional information regarding your variable product add this function to your child themeâs function.php (or plugin). Youâll probably want to alter the html tags to fit your theme: