WPSlash

How to Set Different Minimum Delivery Amounts Per City in WooCommerce

Saturday July 3, 2021

If you’re running a WooCommerce-powered restaurant ordering system, you may want to set different minimum order amounts for delivery based on the customer’s city. This ensures that delivery remains cost-effective for your business, especially when serving multiple locations.

In this guide, we’ll show you how to use a custom PHP snippet to dynamically adjust the minimum delivery amount per city when using WooFood – the WooCommerce food delivery plugin.


Why Set a Minimum Order Amount Based on City?

✔ Ensures profitability – Prevents small orders from being delivered to far locations.
✔ Customizes delivery pricing – Allows businesses to charge differently per area.
✔ Improves efficiency – Encourages larger orders for deliveries in distant locations.
✔ Seamless WooCommerce integration – Works perfectly with the WooFood Plugin.

By implementing this WooCommerce customization, your customers will only be able to place an order if their total meets the minimum required for their selected city.


How to Set a Minimum Delivery Amount Per City in WooFood

To apply different minimum order amounts per city, insert the following PHP snippet into your child theme’s functions.php file:

add_filter("woofood_minimum_amount_delivery_filter", "wpslash_minimum_delivery_hook_on_message_per_city", 10, 1);

function wpslash_minimum_delivery_hook_on_message_per_city($min_amount) {
    global $woocommerce;
    $minimum = array(
        "Niefern" => 8,
        "Niefern-Öschelbronn" => 8,
        "Pinache" => 8,
        "Wiernsheim" => 12,
        "Neubärental" => 12,
        "Großglattbach" => 12,
        "PF-Eutingen" => 13,
        "Enzberg" => 13,
        "Lormersheim" => 13,
        "Mönsheim" => 15,
        "Wimsheim" => 15,
        "PF-Mäurach" => 15,
        "PF-Hagenschieß" => 15,
        "Kieselbronn" => 15,
        "Dürrmenz" => 15,
        "Serres" => 15,
        "Mühlacker" => 17,
        "Mühlacker Mühlhausen" => 17,
        "Sengach" => 18,
        "Iptingen" => 18,
        "PF-Oststadt" => 22,
        "Weissach" => 22,
        "Friolzheim" => 22,
        "PF-Innenstadt" => 25,
        "PF-Südstadt" => 25,
        "Buckenberg" => 25,
        "Haidach" => 25,
        "Nußdorf" => 25,
        "Lienzingen" => 25,
        "Ötisheim" => 25,
        "Corres" => 25,
        "Öt-Erlenbach" => 25,
        "Tiefenbronn" => 25,
        "PF-Nordstadt" => 30,
        "Bauschlott" => 30,
        "Göbrichen" => 30,
        "Ölbronn-Dürrn" => 30,
        "Eberdingen" => 30,
        "Pf-Brötzingen" => 35,
        "Pforzheim" => 35,
        "Weststadt" => 35,
        "Maihälden" => 35,
        "Neulingen" => 35
    );

    $city = str_replace(" ", "", $woocommerce->customer->get_billing_city());

    if (array_key_exists($city, $minimum)) {
        return $minimum[$city];
    }

    return $min_amount;
}

How This Code Works

✅ Filters the minimum order amount for WooFood deliveries based on the selected city.
✅ Uses the customer’s billing city to determine the correct minimum amount.
✅ Ensures that customers cannot place orders unless their total meets the city’s requirement.
✅ Works seamlessly with the WooCommerce checkout process.


How to Add a City Selection Dropdown in WooCommerce Checkout

By default, WooCommerce allows customers to enter their city manually. To ensure accuracy, you can replace this field with a predefined list of cities.

Add the following code snippet to your functions.php file to replace the default city field with a dropdown selection:

add_filter('woocommerce_checkout_fields', function($fields) {
    $minimum = array(
        "Niefern" => 8,
        "Niefern-Öschelbronn" => 8,
        "Pinache" => 8,
        "Wiernsheim" => 12,
        "Neubärental" => 12,
        "Großglattbach" => 12,
        "PF-Eutingen" => 13,
        "Enzberg" => 13,
        "Lormersheim" => 13,
        "Mönsheim" => 15,
        "Wimsheim" => 15,
        "PF-Mäurach" => 15,
        "PF-Hagenschieß" => 15,
        "Kieselbronn" => 15,
        "Dürrmenz" => 15,
        "Serres" => 15,
        "Mühlacker" => 17,
        "Mühlacker Mühlhausen" => 17,
        "Sengach" => 18,
        "Iptingen" => 18,
        "PF-Oststadt" => 22,
        "Weissach" => 22,
        "Friolzheim" => 22,
        "PF-Innenstadt" => 25,
        "PF-Südstadt" => 25,
        "Buckenberg" => 25,
        "Haidach" => 25,
        "Nußdorf" => 25,
        "Lienzingen" => 25,
        "Ötisheim" => 25,
        "Corres" => 25,
        "Öt-Erlenbach" => 25,
        "Tiefenbronn" => 25,
        "PF-Nordstadt" => 30,
        "Bauschlott" => 30,
        "Göbrichen" => 30,
        "Ölbronn-Dürrn" => 30,
        "Eberdingen" => 30,
        "Pf-Brötzingen" => 35,
        "Pforzheim" => 35,
        "Weststadt" => 35,
        "Maihälden" => 35,
        "Neulingen" => 35
    );

    $fields['billing']['billing_city']['type'] = 'select';
    $fields['billing']['billing_city']['options'] = array_merge(array('' => 'Select your city'), $minimum);

    return $fields;
});

Looking for a Complete WooCommerce Food Delivery Solution?

If you’re running a food delivery business using WooCommerce, you need a powerful and flexible system to manage orders efficiently.

WooFood – WooCommerce Food Delivery Plugin is the best solution for restaurants that need:

✅ Custom delivery settings – Set minimum order amounts, delivery zones, and fees.
✅ Real-time order processing – Automatically print and manage orders.
✅ Pickup & delivery options – Allow customers to choose their preferred method.
✅ Seamless WooCommerce integration – Works with any WordPress website.

🚀 Upgrade Your WooCommerce Food Ordering System Today!

👉 Get WooFood here to take your restaurant website to the next level!

Leave a Comment

Your email address will not be published. Required fields are marked *

Related Articles

Restaurants Tutorials

The Cheapest Food Delivery App for Restaurants Isn’t an App at All — It’s WooFood

When restaurant owners start looking for the cheapest food delivery app, they quickly discover a frustrating truth: most “cheap” delivery platforms aren’t cheap at all. They either take commissions, charge high monthly fees, lock you into their payment processors, or limit how much control you have over your own customer base. But what if the […]
December 1, 2025
Restaurants WooFood

Why “Free” GloriaFood Might Not Be The Best Long-Term Bet For Your Restaurant

When you’re building an online ordering system for your restaurant, it’s tempting to go for a “free” solution. That’s exactly what GloriaFood offers: a ready-to-go, easy-to-install WordPress plugin for online ordering, delivery, and reservations with no setup fees or commissions But “free” doesn’t always mean “best,” especially when you’re serious about owning your brand, your […]
December 1, 2025
Tutorials WooCommerce

How to Choose the Best Food Ordering System for Your Restaurant (And Why WooFood is the Ultimate Solution)

If you’re running a restaurant, café, or fast-food business in today’s digital age, offering online food ordering is no longer optional — it’s essential. Customers expect the convenience of browsing your menu, customizing their orders, and checking out seamlessly from their phone or computer. But with so many plugins and systems available, how do you choose the right […]
April 21, 2025