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 custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

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. Follow @rmelogli

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

  1. Thank you for a very nice plugin, how can i use it to find missing images? main image of product

    1. Hello Lars, 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!

  2. 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?

  3. 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!

  4. 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

  5. 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? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. 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 the Business Bloomer Club to get quick WooCommerce support. Thank you!

Your email address will not be published. Required fields are marked *