Product Page

WooCommerce Product Attribute Dimensions (LxWxH) Suffix

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.

100 WooCommerce Conversion Rate Optimisation Tips

This field is for validation purposes and should be left unchanged.

Let’s collaborate!

Need to outsource WordPress development?

Join forces with UnlimitedWP for an outsourced white label web development service you can truly rely on.

First Timer Here?

Sign up to receive 20% off on your first month with us.

26027
WELCOME OFFER