Do you want to display all the all products with no weight in your WooCommerce store? In today’s tutorial, we will show you how to do this without going through all the products in your store.
If you sell physical goods, weight is one of the most important aspects you need to look at. This is because it affects the shipping price. Heavy products should have a relatively higher shipping rate than the other products.
In addition, customers in your store need to know the weight of the products to make a well-informed purchase. This allows them to buy the product they were looking for.
By default, WooCommerce allows you to add the product weight when adding products in the back end. This is a very convenient feature because you can use this information to create favorable shipping rates.
If you have few products, it will be very easy for you to know the products that do not have weight. However, if you have many products, this can be very hard. This is why we decided to create a custom-made solution for you.
Table of Contents
WooCommerce Display All Products With No Weight
By the end of this tutorial, you will be able to display all the products with no weight on the view products page. In this post, we will be using a custom code snippet we specifically made to edit some of WooCommerce’s core files to get the desired result.
Therefore, you should install or create a child theme. This will ensure that your changes will not be lost during an update.
With that in mind, let us get right into it.
Steps to Display All Products With No Weight
Here are the simple steps you need to follow:
- Log into your WordPress site and access the Dashboard as the admin user.
- From the Dashboard menu, click on Appearance Menu > Theme Editor Menu. When the Theme Editor page is opened, look for the theme functions file to add the function to display all products with no weight.
- Add the following code to the functions.php file:
[php]
add_action( ‘admin_notices’, ‘njengah_products_no_weight_admin’ );
function njengah_products_no_weight_admin(){
global $pagenow, $typenow;
if ( ‘edit.php’ === $pagenow && ‘product’ === $typenow ) {
echo ‘<div class="notice notice-warning is-dismissible"><h3>Products with no weight</h3><ul>’;
$args = array(
‘status’ => ‘publish’,
‘visibility’ => ‘visible’,
‘limit’ => -1
);
$products = wc_get_products( $args );
foreach ( $products as $product ) {
if ( ! $product->get_weight() ) {
echo ‘<li><a href="’ . esc_url( get_edit_post_link( $product->get_id() ) ) . ‘">’ . $product->get_name() . ‘</a></li>’;
}
}
echo ‘</ul></div>’;
}
}
[/php]
Wrapping Up
In summary, we have shared a solution to display all the products with no weight on the view product page. The code snippet also adds a link that directs you to the product edit page, where you can add the product’s weight.
However, you should have a complete backup of your site before editing WooCommerce’s core files. This will ensure that you can revert to the previous version if an error occurs.
We hope that this post provided a solution for you.

Joe is an experienced full-stack web developer with a decade of industry experience in the LAMP & MERN stacks, WordPress, WooCommerce, and JavaScript – (diverse portfolio). He has a passion for creating elegant and user-friendly solutions and thrives in collaborative environments. In his spare time, he enjoys exploring new tech trends, tinkering with new tools, and contributing to open-source projects. You can hire me here for your next project.
More articles written by Joe
Similar Articles
- How Can Customer Cancel Order WooCommerce
- How to Customize Product Category Page In WooCommerce
- How to Customize Storefront Theme Using Customizer
- How to Add Local Pickup to WooCommerce
- How to Get WooCommerce Current Order ID from URL
- What is the Difference Between WordPress and WooCommerce Explained
- How to Hide Any Tab My Account Page WooCommerce
- How to Set Up WooCommerce Subscribe or Unsubscribe To Our Newsletter
- How to Add WooCommerce Shipping Calculator on Checkout Page
- How to Upload Image On Product Page In WooCommerce
- How to Set Number of Products Per Page WooCommerce
- How to Set WooCommerce Different Sidebar For Each Category
- How to Use WooCommerce to Set Up Online Store
- How To Edit WooCommerce Checkout Page
- How to Add Custom Background For WooCommerce
- How to Add Custom Product Fields WooCommerce
- WooCommerce vs Magento: Which Is the Best E-Commerce Platform?
- How to Add WooCommerce Products to a Page
- How to Add WooCommerce Shopping Cart Icon In Menu
- How to Add WooCommerce Registration Email Verification