Home » WooCommerce: Shipping by Weight (Without a Plugin!)

WooCommerce: Shipping by Weight (Without a Plugin!)

by adminkys

With WooCommerce Shipping Zones you can use simple PHP to accomplish lots of “advanced” shipping rules, such as shipping by weight.

With many of Business Bloomer fans always asking for this sort of customization, today we’ll see how to do just that. Without the need of just another plugin 🙂

1. Shipping by Weight – Requirements

If you or your client requires shipping by weight, then you first have to make sure ALL simple products and/or single variations have a weight > 0. Pretty simple, but sometimes people ask “Why shipping by weight doesn’t work?”, and the most common mistake is that products have 0 weight!

Also, under WooCommerce > Settings > Products make sure to select the correct “Weight Unit“, another typical error people make (defaults to Kg I believe).

2. Shipping by Weight – Shipping Methods Setup

You can add unlimited Flat Rates to each Shipping Zone. Also, you can rename each flat rate to something like “Orders Below 1kg”, “Orders Above 10kg”, etc to make the checkout label a little more user-friendly.

In our example, we will setup 3 weight tiers:

  • $10 shipping for orders up to 1kg
  • $20 shipping for orders up to 5kg
  • $30 shipping for orders above 5kg

And here is how to set the WooCommerce shipping methods:

  1. Flat Rate #1 > rename to “Orders Below 1kg” and assign cost = $10
  2. Flat Rate #2 > rename to “Orders Below 5kg” and assign cost = $20
  3. Flat Rate #3 > rename to “Orders Above 5kg” and assign cost = $30

Your final result for the specific zone (I called it “USA – Shipping by Weight”) will look like this:

WooCommerce Shipping by Weight (Shipping Zone Setup)
WooCommerce Shipping by Weight (Shipping Zone Setup)

3. Shipping by Weight – PHP Snippet

Now we need to “tell” WooCommerce that, based on the cart weight, a Flat Rate should be used instead of another. Only in this way we can show the correct flat rate to the end user.

First, take a note of the unique ID of the three flat rates. They should look look something like “flat_rate:9“. For more info on how to find them, check here: https://businessbloomer.com/woocommerce-disable-free-shipping-if-cart-has-shipping-class

In my example above, I have the following rate IDs:

  1. Flat Rate #1 > flat_rate:5
  2. Flat Rate #2 > flat_rate:6
  3. Flat Rate #3 > flat_rate:8

Second, let’s code! We’ll need to “unset” rates based on the total weight, so in total we’ll need 3 conditions: when weight is below 1 (kg), below 5 (kg) and above 5.

 * @snippet       Shipping by Weight | WooCommerce
 * @sourcecode    https://tutoraspire.com/?p=21432
 * @author        Tutor Aspire
 * @compatible    WooCommerce 3.7
 * @donate $9     https://www.tutoraspire.com
add_filter( 'woocommerce_package_rates', 'tutoraspire_woocommerce_tiered_shipping', 9999, 2 );
function tutoraspire_woocommerce_tiered_shipping( $rates, $package ) {
     if ( WC()->cart->get_cart_contents_weight() cart->get_cart_contents_weight() 

And here is the proof:

WooCommerce: Shipping by Weight Demonstration
WooCommerce: Shipping by Weight Demonstration

You may also like