Logo
Development

How to Set Up Conditional Delivery Fees in WooCommerce: Free Shipping Within a Local Radius or Over a Minimum Order Amount

August 10, 2025
7 min read

Are you running an online store and want to offer free delivery for local customers or big spenders? In this guide, we’ll show you how to add a fixed delivery fee in WooCommerce that only applies if the customer’s address is outside a specified radius from your store and their order total is below a minimum amount—all for free, without paid plugins or APIs. This setup uses WooCommerce’s built-in features, custom code snippets, and an optional free plugin for postcode enforcement. It’s perfect for small businesses looking to boost local sales while keeping shipping costs fair.

By the end of this post, you’ll have radio buttons on your checkout page letting customers choose between “Free Delivery (within the local radius)” and “Standard Delivery (outside the local radius – fixed fee)”, with automatic adjustments for orders over the minimum amount. Let’s dive in!

Why Use Conditional Delivery Fees in WooCommerce?

Conditional shipping rules like this can increase conversions by rewarding local shoppers and high-value orders. For stores in any town or city, it encourages nearby purchases while covering costs for farther deliveries. Plus, it’s SEO-friendly for searches like “WooCommerce free shipping within radius” or “distance-based delivery fees UK.” This method is budget-friendly, relying on postcode approximations instead of costly Google Maps APIs.

Prerequisites for Setting Up WooCommerce Delivery Fees

  • WooCommerce installed and activated on your WordPress site.
  • Your store currency set appropriately in WooCommerce > Settings > General.
  • Access to edit your theme’s functions.php (or use the free Code Snippets plugin for safer code additions).
  • Optional: The free Booster for WooCommerce plugin for postcode-based restrictions.

Test with postcodes near your store (e.g., central area) and outside the specified radius.

Step 1: Configure Shipping Zones and Methods (Create Radio Buttons)

We’ll set up two flat-rate shipping options that appear as selectable radio buttons on the cart and checkout pages.

  1. Go to WooCommerce > Settings > Shipping > Shipping Zones.
  2. Add or edit a zone (e.g., “UK Delivery”) and select “United Kingdom” as the region.
  3. Add a shipping method: Choose “Flat Rate.”
  4. Edit the first method:
    • Method Title: “Free Delivery (within the local radius)”
    • Tax Status: None (or Taxable).
    • Cost: 0
  5. Add a second Flat Rate method:
    • Method Title: “Standard Delivery (outside the local radius – fixed fee)”
    • Tax Status: None (or Taxable).
    • Cost: [your fixed fee amount, e.g., 8.50]
  6. Save changes. Customers will now see radio buttons to select their option.

Step 2: Add Custom Code for Fee Waiving and Default Selection

Use this PHP code to waive the fixed fee for orders over the minimum amount and default to the standard (paid) option. Paste it into functions.php or via Code Snippets. Adjust the threshold value (e.g., 100) as needed.


// Waive fixed fee if cart > minimum amount (applies to standard method only)
add_filter( 'woocommerce_package_rates', function( $rates, $package ) {
    $cart_total = $package['contents_cost']; // Subtotal before taxes/discounts
    if ( $cart_total > 100 ) { // Replace 100 with your minimum amount
        foreach ( $rates as $rate_id => $rate ) {
            if ( $rate->method_id === 'flat_rate' && strpos( $rate->label, 'Standard Delivery' ) !== false ) {
                $rates[$rate_id]->cost = 0;
                $rates[$rate_id]->label = 'Free Standard Delivery (over minimum amount)'; // Optional: Update label
            }
        }
    }
    return $rates;
}, 10, 2 );

// Default select the standard delivery method
add_filter( 'woocommerce_shipping_chosen_method', function( $default, $rates, $chosen_method ) {
    foreach ( $rates as $rate_id => $rate ) {
        if ( strpos( $rate->label, 'Standard Delivery' ) !== false ) {
            return $rate_id; // Select the standard method by default
        }
    }
    return $default;
}, 10, 3 );

This ensures the fee is added automatically to the subtotal for qualifying orders and waived otherwise.

Step 3: Optional – Enforce with Postcodes Using a Free Plugin

To prevent non-local customers from selecting the free option, use postcode matching with the free Booster for WooCommerce plugin.

  1. Install and activate Booster for WooCommerce.
  2. Go to WooCommerce > Settings > Booster > Shipping & Orders > Shipping Methods by Cities/Postcodes.
  3. Enable the module.
  4. For the “Free Delivery” method, set “Include Postcodes” to a list approximating the local radius from your store (e.g., relevant postcode sectors).
  5. Save. Now, the free option only shows for matching postcodes.

For a precise postcode list, use free tools like FreeMapTools (enter your store’s central postcode, radius: your specified miles).

Testing Your WooCommerce Delivery Fee Setup

  • Cart under the minimum amount, local postcode: Free delivery selected, no fee.
  • Cart under the minimum amount, outside postcode: Fixed fee added automatically.
  • Cart over the minimum amount: All options free.

Clear transients in WooCommerce > Status > Tools if needed.

Conclusion: Optimize Your Store’s Shipping Today

This free WooCommerce setup for distance-based and order-total conditional delivery fees is simple, effective, and SEO-optimized for local searches. It encourages more orders from nearby residents while keeping your operations cost-effective. If you run into issues or need custom tweaks, drop a comment below!

 

Last updated: August 10, 2025

Tags:

Share this article

Search Blog

Popular Posts

How to Choose the Right SSL Certificate

1/12/20241543 views

Website Security Best Practices 2024

1/10/20241287 views

Understanding HTTPS vs HTTP

1/8/2024956 views

Categories

Security
15
SEO
12
Web Development
23
Performance
8
Business
11

Popular Tags

#SSL
#HTTPS
#Security
#SEO
#Performance
#WordPress
#Hosting
#Optimization
#Analytics
#Marketing

Stay Updated

Get the latest articles and insights delivered to your inbox.