WPSlash Licences

Set Different Minimum Delivery Amounts per Store Location

How to Set Different Minimum Delivery Amounts for Each Location in WooFood – code snippet guide from WPSlash
Published
Updated
Reading time
2 minutes
Written by
WPSlash team

This snippet sets a different minimum delivery amount for each store location in FoodMaster (formerly WooFood). Add it to your child theme’s functions.php file, or to a code snippets plugin.

Set the minimum amount per store

The snippet checks the store id sent with the checkout. Replace the ids 35 and 34 and the amounts 20 and 25 with your own.

Code
<?php
add_action( 'woocommerce_checkout_process', 'woofood_custom_hook_minimum_per_store', 9999999 );
 function woofood_custom_hook_minimum_per_store() {
   global $woocommerce;



    if (isset($_POST["extra_store_name"])) {

      //35 is the store id //

    if ($_POST["extra_store_name"] == "35")
    {
          wc_add_notice( 
                sprintf(  __( 'You must have an order with a minimum of %s to place your order, your current order total is %s.', 'woofood-plugin' ) , 
                    wc_price( 20 ), 
                    wc_price( WC()->cart->subtotal )
                ), 'error' 
            );

    }
          //34 is the store id //

    else if($_POST["extra_store_name"] == "34")
    {
         wc_add_notice( 
                sprintf(  __( 'You must have an order with a minimum of %s to place your order, your current order total is %s.', 'woofood-plugin' ) , 
                    wc_price( 25 ), 
                    wc_price( WC()->cart->subtotal )
                ), 'error' 
            );
    }

      

    }
}

?>

How the snippet works

The function woofood_custom_hook_minimum_per_store() runs on woocommerce_checkout_process. It reads extra_store_name from the posted checkout data and, when the value matches a store id in the snippet, adds an error notice with wc_add_notice(). The notice shows the minimum amount and the current cart subtotal, and it stops the order from going through.

Before you start

  • Set up your store locations in FoodMaster first, so the store ids exist.
  • Change the store ids and the amounts in the snippet to match your own locations.
  • Test on a staging site before you use it on the live shop.

To check it worked, choose a store at the checkout and place a test order. The error notice should appear with the minimum amount for that store.

FoodMaster (formerly WooFood)

The snippet uses hooks from FoodMaster (formerly WooFood), the restaurant ordering plugin for WooCommerce. You can get FoodMaster here.

FoodMasterRestaurant ordering for WooCommerce: delivery, pickup and dine-in, a POS for counter and phone orders, a kitchen display and automatic ticket printing. Used by 10,000+ restaurants.$499 for one site
All guides

FoodMaster (formerly WooFood)12 min read

Best Store Address Setup for Pickup

Compare single-address, multi-location, and directions-first pickup setups to reduce wrong-door visits and simplify checkout.

The plugins these guides are about

FoodMaster for restaurants, courier vouchers for the Greek market, marketplace sync and store tools, all for WooCommerce.

Browse plugins30-day money-back on every plugin