Website Building » WooCommerce » How Do I Set Free Shipping on a Certain Amount in WooCommerce?

How Do I Set Free Shipping on a Certain Amount in WooCommerce?

Last updated on January 12, 2023 @ 12:08 pm

When it comes to eCommerce, one of the most important factors is shipping. If you don’t get your shipping right, it can be the difference between a successful online store and one that flops.

That’s why it’s so important to offer free shipping on orders over a certain amount. This not only encourages people to spend more in your store, but it also helps to offset the cost of shipping and makes your customers feel like they’re getting a good deal.

There are a few different ways to set up free shipping in WooCommerce. You can either use a plugin or edit your theme’s code.

If you’re using a plugin, there are a few different options to choose from. Free Shipping by WooCommerce is a popular choice, as it’s easy to set up and use. Another option is Shipping Zones by WooCommerce, which lets you set up free shipping for specific geographic regions.

If you want to edit your theme’s code, you’ll need to add a few lines of code to your functions.php file. First, you’ll need to add a filter for the ‘woocommerce_package_rates’ hook.

This hook allows you to modify the shipping rates that are returned by WooCommerce. Next, you’ll need to add a function that checks the order total and modifies the shipping rates accordingly.

Here’s an example of how this code would look:

function my_free_shipping_threshold( $rates ) {
  $total = WC()->cart->get_subtotal();
    if ( $total >= 500 ) {
     foreach ( $rates as $rate_key => $rate ) {
      if ( 'flat_rate' === $rate->method_id ) {
      $rates[$rate_key]->cost = 0;
      break;
      }
    }
 }
return $rates;
}
add_filter( 'woocommerce_package_rates', 'my_free_shipping_threshold', 10, 2 );

In this example, we’ve set the free shipping threshold at $500. You can change this amount to whatever you like.

We’ve also used the flat rate shipping method as an example, but you can use any shipping method that you like. Just be sure to change the ‘flat_rate’ part of the code to match the ID of your chosen shipping method.

Once you’ve added this code, free shipping will be automatically enabled for orders over the specified amount. If you want to take things a step further, you can also add a message to your cart page letting people know that they qualify for free shipping. To do this, you can use the WooCommerce_cart_needs_shipping() hook like this:

function my_show_free_shipping( $needs_shipping ) {
  global $woocommerce;
   $total = WC()->cart->get_subtotal();
   if ( $total >= 500 ) {
   return false; }
   else { return $needs_shipping; } }
add_filter( 'woocommerce__cart__needs__shipping', 'my__show__free__shipping' );

In this example, we’re checking if the order total is greater than or equal to $500. If it is, we’re returning false, which tells WooCommerce not to display the shipping message.

Otherwise, we’re returning the default value (true). This will ensure that people only see the free shipping message if their order qualifies for it.

There are a few other things that you can do with this code as well. For example, you could add conditions for specific products or product categories.

Or, you could add a minimum order quantity requirement instead of (or in addition to) a minimum order total. The possibilities are endless!

PRO TIP: If you are using WooCommerce to set up free shipping on your website, be aware that there is a potential security flaw in the system. A user with malicious intent could exploit this flaw to gain access to your website’s shipping information.

Setting up free shipping in WooCommerce is easy and encourages customers spend more money in your store.

Madison Geldart

Madison Geldart

Cloud infrastructure engineer and tech mess solver.