• Resolved dan11

    (@dan11)


    Under the Additional Information tab, I want to display each dimension (Length, Width, Height) in a separate line

    Instead of:

    Display this:

    How do I do that?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Copy product-attributes.php from /plugins/woocommerce/templates/single-product/ folder to /themes/your_theme/woocommerce/single-product/ folder, then edit it and replace

    	<?php if ( $display_dimensions && $product->has_dimensions() ) : ?>
    		<tr>
    			<th><?php _e( 'Dimensions', 'woocommerce' ) ?></th>
    			<td class="product_dimensions"><?php echo esc_html( wc_format_dimensions( $product->get_dimensions( false ) ) ); ?></td>
    		</tr>
    	<?php endif; ?>

    with

    	<?php if ( $display_dimensions && $product->has_dimensions() ) : ?>
    		<tr>
    			<th>Length</th>
    			<td class="product_dimensions"><?php echo $product->get_length() . get_option( 'woocommerce_dimension_unit' ); ?></td>
    		</tr>
    		<tr>
    			<th>Width</th>
    			<td class="product_dimensions"><?php echo $product->get_width() . get_option( 'woocommerce_dimension_unit' ); ?></td>
    		</tr>
    		<tr>
    			<th>Height</th>
    			<td class="product_dimensions"><?php echo $product->get_height() . get_option( 'woocommerce_dimension_unit' ); ?></td>
    		</tr>
    	<?php endif; ?>
    • This reply was modified 7 years, 5 months ago by superkot.
    Thread Starter dan11

    (@dan11)

    Works beautifully, thanks so much
    I wonder if it would be possible to add a custom dimension, like a diameter or seat-height? How would I go about doing that?

    Thread Starter dan11

    (@dan11)

    I was able to achieve what I was trying with the above replacement code thank you!

    But how can I make it so if the product doesn’t have length, there will be no “Length” row?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display dimensions in separate lines’ is closed to new replies.