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

Tutorials

How to Set Up SMS and WhatsApp Order Notifications for Your WooCommerce Restaurant (2026)

Why SMS and WhatsApp Notifications Matter for Restaurant Orders A customer places an order on your <a href="https://www.wpslash.com/how-to-set-up-real-time-order-tracking-for-your-woocommerce-restaurant-website-2025-2/" title="How to Set Up Real-Time Order Tracking for Your <a href="https://www.wpslash.com/how-to-set-up-catering-and-large-group-orders-on-your-woocommerce-restaurant-website-2025/" title="How to Set Up Catering and Large Group Orders on Your WooCommerce Restaurant Website (2025)”>WooCommerce Restaurant Website (2025)”>restaurant website at 7:15 PM during the Friday rush. […]
May 3, 2026
Tutorials

How to Set Up Real-Time Order Tracking for Your WooCommerce Restaurant Website (2026)

Why Real-Time Order Tracking Matters for Restaurant Websites Picture this: a hungry customer places an order on your <a href="https://www.wpslash.com/how-to-build-a-customer-loyalty-program-for-your-wordpress-restaurant-website-2025/" title="How to Build a Customer Loyalty Program for Your <a href="https://www.wpslash.com/how-to-connect-your-wordpress-restaurant-website-to-doordash-uber-eats-grubhub-2025/" title="How to Connect Your WordPress <a href="https://www.wpslash.com/how-to-rank-your-restaurant-website-on-google-local-seo-for-wordpress-2025/" title="How to Rank Your Restaurant Website on Google: Local SEO for WordPress (2025)”>Restaurant Website to DoorDash, Uber […]
May 3, 2026
Tutorials

How to Set Up Catering and Large Group Orders on Your WooCommerce Restaurant Website (2026)

Why Catering and Large Group Orders Matter for Restaurant Revenue Most restaurant owners pour energy into optimizing their dine-in experience and individual delivery orders while overlooking a revenue channel that can transform their bottom line: catering. A single corporate lunch order for 30 people can equal what your dining room generates in an entire slow […]
May 2, 2026