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!
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>';
}
}
Thank you for a very nice plugin, how can i use it to find missing images? main image of product
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!
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
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.
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!
I’d say this snippet fully works for simple products only. Can you confirm?
Great!
How can I display the products variations with no Weight?
Thank you.
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!
Thanks, this is will be very useful. What is the purpose of the $products_no_weight array? It doesn’t appear to exist.
Hi Jason, you can remove that line, mistake of mine
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)?
more details….
Perhaps it would be interesting to display it in the list when any of this data was missing: Height, Length, Width.
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!