WooCommerce Product Attribute Dimensions (LxWxH) Suffix

Pre-Requisites

There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About this Solution

For some products, it be necessary to make clear that the dimensions planes listed in the attributes table is in the format Length x Width x Height. This guide shows you how you can add the suffix (LxWxH) to the product dimensions shown in the attributes table under the Additional Information tab.

				
					/**
 * Snippet Name:	WooCommerce show product attribute dimensions (LxWxH) suffix
 * Snippet Author:	ecommercehints.com
 */
 
add_filter( 'woocommerce_format_dimensions', 'ecommercehints_dimensions_suffix', 20, 2 );
function ecommercehints_dimensions_suffix( $dimension_string, $dimensions ) {
    $dimension_string = implode( ' x ', array_filter( array_map( 'wc_format_localized_decimal', $dimensions ) ) );
    if ( ! empty( $dimension_string ) ) 
        $dimension_string .= ' ' . __("(LxWxH)", "woocommerce");
    return $dimension_string;
}
				
			

Snippet Benefits

  • Make it clear to customers the dimension planes for your products.
WooCommerce Conversion Rate Optimisation (CRO) eBook
100 WooCommerce Conversion Rate Optimisation Tips

Leave a Reply

If you are going to write code in the comments, please wrap it between code tags.

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

Other Recent Guides

Subscribe To Emails

Get exclusive WooCommerce tips that I only share with email subscribers

Join hundreds of other subscribers