WPSlash Licences

Change Delivery Time by Day of the Week in WooCommerce

How to Dynamically Change Delivery Time Based on the Day in WooCommerce – code snippet guide from WPSlash
Published
Updated
Reading time
1 minutes
Written by
WPSlash team

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_.

Code
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 if blocks 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.

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