This snippet changes the delivery and pickup time in FoodMaster (formerly WooFood) depending on the day of the week. Add it to your child theme’s functions.php file, or to a code snippets plugin.
Set a different time for each day
The snippet returns 45 on Monday, 30 on Tuesday and 60 on Wednesday. Change those values, or add more days, to match your kitchen.
Updated for current FoodMaster versions: the code below uses the foodmaster_ names. Older installs that still run WooFood used the woofood_ prefix, so on those change foodmaster_ back to woofood_.
add_filter( 'foodmaster_adjust_delivery_time_thankyou', 'wpslash_custom_hook_dynamically_change_pickup_time', 10, 2 );
add_filter( 'foodmaster_adjust_pickup_time_thankyou', 'wpslash_custom_hook_dynamically_change_pickup_time', 10, 2 );
function wpslash_custom_hook_dynamically_change_pickup_time( $time, $order_id ) {
$current_day_name= current_time("l");
if($current_day_name == "Monday")
{
return "45";
}
if($current_day_name == "Tuesday")
{
return "30";
}
if($current_day_name == "Wednesday")
{
return "60";
}
return $time;
}How the snippet works
The function hooks into foodmaster_adjust_delivery_time_thankyou and foodmaster_adjust_pickup_time_thankyou. It reads the current day with current_time("l") and returns the matching value. On any other day it returns the time it was given.
Before you start
- Change the time values to match your own preparation times.
- Add more
ifblocks for the other days of the week. - Test on a staging site before you use it on the live shop.
To check it worked, place a test order on a day you have set and look at the delivery or pickup time on the order confirmation.
FoodMaster (formerly WooFood)
The snippet uses filters from FoodMaster (formerly WooFood), the restaurant ordering plugin for WooCommerce. You can get FoodMaster here.
