Set Different Minimum Delivery for Each Location on WooFood

June 14, 2021

TutorialsWooFood
woocommerce food orderingwordpress food ordering plugin

You can use the following code snippet under your functions.php to set a different minimum delivery for each location .

<?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' 
            );
    }

      

    }
}

?>