Set a Minimum Order amount for Pickup(Takeaway) Orders

Here is a small snippet on how to set a minimum amount for Pickup (Takeaway) Orders on WooFood .

Just copy and paste the following code snippet your functions.php on your child theme.

add_action( 'woocommerce_checkout_process', 'woofood_custom_hook_minimum_pickup_orders', 9999999 );
 function woofood_custom_hook_minimum_pickup_orders() {
   global $woocommerce;
    $minimum = 20;
	if ( WC()->cart->subtotal < $minimum && (isset($_POST["woofood_order_type"]) && ($_POST["woofood_order_type"] == "pickup")  ) ) {
		wc_print_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( $minimum ), 
                    wc_price( WC()->cart->subtotal )
                ), 'error' 
            );

	}
}