Add Custom Message on Availability Checker Response

January 8, 2021

TutorialsWooFood
woocommerce food orderingwordpress food ordering plugin
add_filter('woofood_availability_checker_after_response', 'woofood_hook_add_message_after_availability_checker', 10, 4);

function woofood_hook_add_message_after_availability_checker($default, $order_type, $available, $billing_postcode)
{

	$minimum = array();
    //add postal code to array with value the minimum amount without spances//
    $minimum["5722"] = 20;
    $minimum["3423"] = 30;
    $minimum["3425"] = 40;
    $minimum["3427"] = 40;
    $minimum["3424"] = 40;
    $minimum["3426"] = 50;
    $minimum["3473"] = 60;
	
	if ( $order_type == "delivery") {


    if (array_key_exists($billing_postcode, $minimum)  )
    {
		return "Minimum Delivery is ". wc_price($minimum[$billing_postcode]);
         

    }
    else if(!array_key_exists($billing_postcode, $minimum))
    {
        return "Sorry We are not delivering to this postal code";
    }

      

    }
	
}