🎉 Black Friday Month Deal: Save 20% on Premium Bundles! Create Unlimited Shipping Scenarios with ease. Don’t hesitate—offer ends November 30th 🚀  Learn more →

How to set max weight in WooCommerce orders?

WooCommerce Weight Based Shipping
Author Bartosz Gajewski
Updated:
2019-08-17
Reading time:
3 minutes read

In this article, I’ll show you how to set max weight in WooCommerce orders so you don’t overpay for your shipping. As a bonus, I’ll give you a different solution – setting up weight based shipping with the free plugin.

Sometimes as a WooCommerce store owner, you want to limit your orders. Shipping heavy products or big orders can cost you a lot. In this case, you can just set max weight in WooCommerce orders.

How to set max weight in WooCommerce orders?

The simplest solution would be to add function to your store. You can copy and paste this code into your theme’s functions.php file.

In wc_add_notice section (line 7) you can edit or remove notice that will appear in customers card if it’s content weight would be higher than the set limit. You can set the limit on line 6.

How to do it better?

If you don’t want to overpay for shipping heavy products you can also set up weight based shipping and charge your customers for heavy orders. It’s really simple. All you need is a free version of the Flexible Shipping plugin.

Flexible Shipping WooCommerce

The best Table Rate Shipping for WooCommerce. Period. Create shipping rules based on weight, order totals or item count.

Go to WordPress.org or Download for free
100,000+ Active Installations
30-day money back guarantee
Last Updated: 2024-11-20
Works with WooCommerce 9.1 - 9.5.x

Flexible Shipping is a very popular table rate shipping plugin with more than 245,546 stores using it on a daily basis. In the free version, you can set shipping rates based on price and weight. It also gives you an option to adjust free shipping for your customers.

Weight Based Shipping

To charge your clients for heavy shipping, download and install the Flexible Shipping plugin. Then, go to WooCommerce → Settings → Shipping and choose the shipping zone in which you want to add weight based shipping or make a new one.

Choose shipping zone in WooCommerce

The next step is to add the shipping method and choose Flexible Shipping method as in the screenshot below.

Add flexible shipping method in WooCommerce

Now, edit that shipping method. Enable it and enter Method Title and Method Description. To set weight based shipping click on Add rule button. 

Set new shipping method in WooCommerce

For every rule, in Based on field, choose Weight and set weight range. In this example, I’ll charge $20 for every 20 kilograms of order’s weight. 

Set max weight rules for WooCommerce orders

And that’s it! Of course, you can do it more efficient with the PRO version of Flexible Shipping plugin with progressively increasing weight based shipping, but I still think that it’s a better solution then to set max weight in WooCommerce orders. It’s a win-win situation – clients are not limited and you don’t overpay for shipping.

Display custom notice for overweight orders

But what about customers whose shopping cart weight exceeds the acceptable threshold? By default, they will get a message about the lack of available shipping methods. In most cases, this will result in cart abandonment or, at best, a desperate search to contact the store. However, a much better solution is to replace the default message with your own message. WooCommerce does not allow such an option, but fortunately, there is a simple and free solution for this – Shipping Notices plugin. It allows you to replace the default “No shipping found” notice with your custom text. You can even decide where the notice should be displayed: cart, checkout, or both of them.

Get Free Shipping Notices Plugin →

This way you can easily add information about the maximum allowable weight for shipping or put your contact information there for a customized shipping quote. This simple solution can save many orders.

If you want to get detailed information about it, read our how to change the “No shipping options were found” message tutorial

Summary

Sometimes you don’t want to or can’t offer your customers unlimited order weight. In this case you can set max weight in WooCommerce orders. But if you don’t want to overpay for shipping you can set weight based shipping with free Flexible Shipping plugin.

Comments
Subscribe
Notify of
guest
8 Comments
Inline Feedbacks
View all comments
bill
bill
4 years ago

I’m not quite sure how old this is, but I am wondering with this bit of code, will it also prohibit someone from checking out if the cart exceeds the allowable amount/? Or will it just display the notice?

Thanks!
Dan

Łukasz Spryszak
Łukasz Spryszak
Reply to  bill
4 years ago

Hi Dan, using the snippet above will result in displaying the following error notice in the cart: [Image no longer available] and preventing the customer from reaching the checkout page.

Customer Care
Customer Care
4 years ago

There is syntax error on thecomment image spacing of the code. Could you please help what should i do with it?

These are my codes:

add_action(‘woocommerce_check_cart_items’,’check_cart_weight’);

function check_cart_weight(){
global $woocommerce;
$weight = $woocommerce->cart->cart_contents_weight;
if( $weight > 30 ){
wc_add_notice( sprintf( __( ‘Youhave %sKg weight and we allow only 30Kg of weight per order; Please split your order into a few purchases. Thank you for your kind understanding.’, ‘woocommerce’ ), $weight ), ‘error’ );
}
}

Łukasz Spryszak
Łukasz Spryszak
Reply to  Customer Care
4 years ago

Hi Customer Care, I believe the syntax error you’ve mentioned is related to the fact you are using the incorrect quotation marks in the snippet above. Please try using instead of ‘’.

Customer Care
Customer Care
Reply to  Łukasz Spryszak
4 years ago

Hi Lukasz

Thank you for your email.
Can you advise whether i can allow self pick up even it is more than 30kg?
How should the code look like?

Regards

Michelle Lee

Łukasz Spryszak
Łukasz Spryszak
Reply to  Customer Care
4 years ago

Hi Michelle, I believe in such case you can simply add the default WooCommerce Local Pickup shipping method which would be available all the time for all the orders, no matter what’s their weight.

manx
manx
3 years ago

Hi,
is there possibility to modify this code to work with shipping classes? I have 3 shipping classes, and for each of them I want to set different weight limits. Is this possible?

Łukasz Spryszak
Łukasz Spryszak
Reply to  manx
3 years ago

Hi Manx, the shipping classes are supported and this feature is available by default in our Flexible Shipping PRO plugin.

Last edited 2 years ago by Bartosz Gajewski