How to hide weight and dimensions in WooCommerce Product Additional Information

woocommerce-guide-how-to-hide-dimensions-and-weight-in-additional-information

WooCommerce is one of the most popular eCommerce plugins for WordPress, and it comes packed with many useful features that allow store owners to customize their products. However, sometimes certain product details, such as weight and dimensions, don’t need to be visible to customers. This is particularly true if your products don’t rely on specific weights and sizes to make purchasing decisions, or if you want to simplify the product page.

In this guide, we’ll walk you through a quick solution to disable the display of weight and dimensions in WooCommerce’s “Additional Information” tab. We’ll provide you with an easy-to-use code snippet and a thorough explanation of how it works.

How to Disable Weight and Dimensions in WooCommerce

To hide the weight and dimensions of all products in WooCommerce, you can use a small code snippet. This code will completely remove the display of weight and dimensions from the Additional Information tab on each product page.

Follow these steps to add the code:

  1. Access Your Theme’s Functions.php File: Go to your WordPress dashboard, navigate to Appearance > Theme File Editor, and open the functions.php file of your active theme. Alternatively, use an FTP client or cPanel if you prefer editing files directly.
  2. Add the Code: Copy the code below and paste it at the end of the functions.php file. Make sure to save your changes.
// Remove weight and dimensions from WooCommerce Additional Information tab
add_filter( 'wc_product_enable_dimensions_display', '__return_false' );

Save the File: Once you’ve added the code, save your changes. You can now go to any product page on your site to verify that the weight and dimensions fields have been removed from the Additional Information tab.

Why Hide Weight and Dimensions in WooCommerce?

  1. Non-Physical Products: If you sell virtual products (like digital downloads) or services, these fields might not be relevant.
  2. Simplified Product Pages: If weight and dimensions aren’t essential for your customers to know, hiding them can make your product pages look cleaner.
  3. Enhanced User Experience: Showing only relevant information can improve the customer experience by reducing unnecessary data.
  4. Avoid Customer Confusion: If you add dimensions both as product attributes (actual dimensions) and in the shipping settings (package dimensions), the information may become confusing for customers. This is especially relevant when the product’s real dimensions differ from the box dimensions, as is often the case with items that aren’t perfectly rectangular. Hiding dimensions in the Additional Information tab can prevent misunderstandings about the product’s actual size and ensure a clearer presentation.

How the Code Works

This line of code might look simple, but it’s powerful! Let’s break down what each part does:

  • add_filter: In WordPress, the add_filter function is used to modify (or “filter”) the default behavior of a function or setting. In this case, we’re using it to filter WooCommerce’s display settings.
  • wc_product_enable_dimensions_display: This is a WooCommerce filter hook. It controls the display of product dimensions (weight and size) in the Additional Information tab. By default, WooCommerce uses this hook to display weight and dimensions if they are set in the product’s shipping details.
  • __return_false: This part is a built-in WordPress function that simply returns false. By using __return_false as the callback function for this filter, we’re telling WooCommerce to “return false,” which effectively disables the display of weight and dimensions.

In simpler terms, this code tells WooCommerce: “Do not display product dimensions or weight on the product page.”

Benefits of Using This Code

  • No Plugins Needed: Instead of installing an additional plugin, you can use this simple code to achieve the same result, saving on page load times and reducing potential plugin conflicts.
  • Easy to Customize: If you only want to hide weight or dimensions but not both, you can further modify this code. However, by default, it removes both fields.

Frequently Asked Questions

1. Will this code affect my product shipping settings?

No, this code only hides the display of weight and dimensions on the product page. WooCommerce will still use weight and dimensions for shipping calculations if you’ve set them up for that purpose.

2. Can I show weight or dimensions only for specific products?

This code is a global setting, so it applies to all products. If you want more control, you would need a custom solution that checks for specific product IDs before hiding the details.

3. Is this change permanent?

No, if you ever want to display the weight and dimensions again, simply remove the code from your functions.php file, and they’ll reappear on all product pages.

Final Thoughts

Disabling the weight and dimensions display in WooCommerce is an effective way to simplify your product pages and improve the user experience for your customers. Using this code snippet is a quick, plugin-free method that’s easy to implement.

We hope this guide helped you understand not only how to hide these fields but also the mechanics behind the code. As always, remember to test your changes on a staging site if possible before making adjustments on a live site.

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on pinterest
Pinterest
Dawid Jaloszynski
Dawid Jaloszynski
Dawid Jaloszynski is the Founder & Web Designer at Lizardo Agency. He is also an expert in search engine optimization (SEO). Dawid is passionate about helping businesses succeed online, and he loves seeing the results of his work when a client's website ranks high in search engines.