Set an upper or lower weight limit for the shopping cart and prevent checkout.
Of course this is possible and the sample code in the post demonstrated this.
We exchanged a few emails and Kyle explained that he was looking to limit the cart weight because his carrier had an upper weight limit. I explained that the ‘woocommerce_no_shipping_available_html’ filter would not be useful here as it only displays a message and would not prevent the checkout process from continuing. Furthermore, it may not be triggered if the user’s address has available shipping methods.
I did a quick search and found a short post on the very topic: How To Set Purchase Limits On Your WooCommerce Cart. It has code for minimum weight and minimum money amounts for the cart.
Set Minimum Cart Weight
I adapted the minimum weight snippet, removing the unnecessary reference to the global $woocommerce variable and changing the legacy ‘cart_contents_weight’ member variable to the get_cart_contents_weight() function. I also removed the is_cart() and is_checkout() checks because the do_action() call only runs on those pages and hence the checks are unnecessary.
Set Maximum Cart Weight
This code is very similar to the minimum cart weight snippet, with just a change in the calculation and the error message text.