How to Display Product Dimensions and Weight on the WooCommerce Cart Page – 2026

Last updated on December 11th, 2024 at 07:25 am

Adding product dimensions and weight to the WooCommerce cart page can help customers better understand the products they’re purchasing. This feature is particularly useful for stores selling physical goods like furniture, appliances, or parcels where size and weight matter for shipping.

In this guide, we’ll show you how to dynamically display product dimensions and weight on the WooCommerce cart page, all without using a plugin.


Step 1: Add Dimensions and Weight Data to Cart Items

To display dimensions and weight, you first need to pass this data to each cart item so it’s accessible on the cart page.

Code to Include Dimensions and Weight in Cart Data

Add the following code to your theme’s functions.php file or a child theme:

/*
 * Snippet: How to Display Product Dimensions and Weight on the WooCommerce Cart Page – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1763
* Tested with WooCommerce 10.7.0
* "This function adds product dimensions and weight to cart item data"
*/ function wcsuccess_add_dimensions_to_cart_item( $cart_item_data, $product_id, $variation_id ) { $product = wc_get_product( $variation_id ? $variation_id : $product_id ); $cart_item_data['dimensions'] = $product->get_dimensions(); $cart_item_data['weight'] = $product->get_weight(); return $cart_item_data; } add_filter( 'woocommerce_add_cart_item_data', 'wcsuccess_add_dimensions_to_cart_item', 10, 3 );

Explanation:

  • Cart Item Data: Adds dimensions and weight to each cart item when it’s added to the cart.
  • Dynamic Product Type: Handles both simple and variable products by checking $variation_id.

Step 2: Display Dimensions and Weight on the Cart Page

Next, use a WooCommerce hook to display the dimensions and weight below each product name in the cart table.

Code to Display Dimensions and Weight

Add this code to your functions.php file:

/*
 * Snippet: How to Display Product Dimensions and Weight on the WooCommerce Cart Page – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1763
* Tested with WooCommerce 10.7.0
* "This function displays product dimensions and weight on the cart page"
*/ function wcsuccess_display_dimensions_in_cart( $cart_item, $cart_item_key ) { $product = $cart_item['data']; $dimensions = $product->get_dimensions(); $weight = $product->get_weight(); if ( ! empty( $dimensions ) || ! empty( $weight ) ) { echo '<div class="product-meta" style="font-size: 14px; color: #555; margin-top: 5px;">'; if ( ! empty( $dimensions ) ) { echo '<strong>Dimensions:</strong> ' . esc_html( wc_format_dimensions( $dimensions ) ) . '<br>'; } if ( ! empty( $weight ) ) { echo '<strong>Weight:</strong> ' . esc_html( $weight ) . ' ' . get_option( 'woocommerce_weight_unit' ) . '<br>'; } echo '</div>'; } } add_action( 'woocommerce_after_cart_item_name', 'wcsuccess_display_dimensions_in_cart', 10, 2 );

Explanation:

  • Dimensions and Weight Display: Fetches and formats the dimensions and weight for each product in the cart.
  • Dynamic Units: Automatically applies WooCommerce settings for weight units (e.g., kg or lbs).
See also  WooCommerce Dynamic Pricing Based on Cart Contents - 2026

Step 3: Add Optional Styling for Dimensions and Weight

To ensure the dimensions and weight display neatly on the cart page, add some custom CSS.

CSS for Dimensions and Weight

Add this CSS to your theme’s style.css file or the WordPress customiser:

.product-meta {
    font-size: 14px;
    color: #555;
    margin-top: 5px;
}

.product-meta strong {
    font-weight: bold;
    color: #333;
}

Explanation:

  • Font and Colour: Sets the dimensions and weight text to a smaller font size with a light grey colour for subtlety.
  • Styling for Labels: Highlights the labels (e.g., “Dimensions” and “Weight”) in bold.

Step 4: Test the Functionality

Example Workflow:

  1. Add Products to Cart:
    • Add one or more products with dimensions and weight to the cart.
  2. View the Cart Page:
    • Confirm that the dimensions and weight are displayed under each product name.
  3. Adjust Styling:
    • Use the provided CSS to ensure the layout matches your store’s design.

Example Use Case

  1. Product Setup:
    • Ensure your products have dimensions (length, width, height) and weight configured in WooCommerce.
  2. Front-End Display:
    • Dimensions like “10 x 20 x 30 cm” and weight like “2 kg” appear below each product in the cart table.
  3. Enhanced User Experience:
    • Provides customers with important details, improving transparency and satisfaction.
See also  How to Add a Sale Countdown Timer to WooCommerce Without a Plugin - 2026

Conclusion

Displaying product dimensions and weight on the WooCommerce cart page is a simple way to provide customers with useful information. By following this guide, you can enhance the shopping experience while making your store more transparent and user-friendly.

Test these changes in a staging environment before deploying them to your live site. For more WooCommerce customisation tips, check out our WooCommerce Visual Hooks Guide or use our wp-config generator for advanced configurations.

0 0 votes
Article Rating

Stay In Touch

Was this post helpful? Why not show your support and buy me a coffee?

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Scroll to Top
0
Would love your thoughts, please comment.x
()
x
×