WooCommerce: Find Products With No Weight @ WP Admin

If your shipping rates depend on product weight, it is very likely you’ve forgotten to add weight to ALL your products. In this way, some shipping rates may be underestimated on the WooCommerce Checkout page.

So, here’s how to print a notice on the WordPress Dashboard > Products screen with a list of products that have no weight, together with the links to edit them quickly.

This is a handy snippet you can reuse for other case scenarios such as easily finding products with no dimensions, no prices, no images, no custom field value, or even a specific weight or given price. Enjoy!

Here’s my custom notice with the list of products that have no weight. Now I can click on each link to edit each single product directly.

PHP Snippet: Display List of Products With No Weight @ WP Dashboard > Products

add_action( 'admin_notices', 'bbloomer_products_no_weight_admin' );

function bbloomer_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>';
    }
}

Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (delete "?>" if you have it there). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.3.

If you think this code saved you time & money, feel free to join 14,000+ WooCommerce Weekly subscribers for blog post updates or 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce?

Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

11 thoughts on “WooCommerce: Find Products With No Weight @ WP Admin

  1. This is really great! We have 90 products, with 4 variations. These do not change, (once a year at the most) we thought we had every variation with weight, so added this out of curiosity, and it brought up quite a few!
    Thank you
    Amy

    1. PS
      I am going through the list and the ones that I have done are still there – I have cleared cache/refreshed etc, that is the only slight fault.

      1. sorry – running notes here
        it is not working correctly. The list has products where all the weights are there and correct. It was only the first few which needed to be changed (all had one variation which is not enabled atm)
        thank you anyway!

        1. I’d say this snippet fully works for simple products only. Can you confirm?

  2. Great!
    How can I display the products variations with no Weight?
    Thank you.

    1. Hi Paulo, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  3. Thanks, this is will be very useful. What is the purpose of the $products_no_weight array? It doesn’t appear to exist.

    1. Hi Jason, you can remove that line, mistake of mine

  4. Hi, Rodolfo

    Great!!!
    I found this incredible, it really is very useful.

    How do I get the list of products without dimension information (height x width x length)?

    1. more details….

      Perhaps it would be interesting to display it in the list when any of this data was missing: Height, Length, Width.

      1. Hi Lucas, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

Questions? Feedback? Support? Leave your Comment Now!
_____

If you are writing code, please wrap it between shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)

Your email address will not be published.