Dynamically Change Average Delivery/Pickup Time Based on Store
January 18, 2021
TutorialsWooFood
woocommerce food orderingwordpress food ordering plugin
The following snippet will help you dynamically change the Average Delivery/Pickup time based on Store ID , so you will be able to set different delivery time for each location .
Copy and paste the following snippet to your functions.php and adjust it to your needs
add_filter( 'woofood_adjust_delivery_time_thankyou', 'wpslash_custom_hook_dynamically_change_pickup_time', 10, 2 );
add_filter( 'woofood_adjust_pickup_time_thankyou', 'wpslash_custom_hook_dynamically_change_pickup_time', 10, 2 );
function wpslash_custom_hook_dynamically_change_pickup_time( $time, $order_id ) {
$store_id = intval(get_post_meta($order_id, 'extra_store_name', true));
if($store_id == 1698)
{
return "45";
}
if($store_id == 2688)
{
return "30";
}
if($store_id == 2689)
{
return "60";
}
return $time;
}
You can use also the following snippet to adjust also the time slots on checkout page to calculate each store average delivery time
add_filter( 'woofood_adjust_pickup_time_multistore_checkout', 'wpslash_custom_hook_dynamically_change_pickup_time_checkout', 10, 2 );
add_filter( 'woofood_adjust_delivery_time_multistore_checkout', 'wpslash_custom_hook_dynamically_change_pickup_time_checkout', 10, 2 );
function wpslash_custom_hook_dynamically_change_pickup_time_checkout( $time, $store_id ) {
if($store_id == 1698)
{
return "45";
}
if($store_id == 2688)
{
return "30";
}
if($store_id == 2689)
{
return "60";
}
}