Created
October 11, 2019 04:48
-
-
Save PluginHive/e1b52a536f7a4fb278d60d7effe03e7b to your computer and use it in GitHub Desktop.
This snippet is used to display cost below the time displayed in time calendar(minutes and hours)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('ph_bookings_calendar_time_slot_value', 'display_cost_below_time', 10, 4); //This filter is used to display cost below the time displayed in time calendar(minutes and hours) | |
function display_cost_below_time($start_time_wp_format, $product_id, $interval, $start_time) | |
{ | |
$currency = get_woocommerce_currency_symbol(); | |
$weekdays_price = 400; //default price for weekdays(Monday to Friday) | |
//change price for weekdays according to time ranges | |
if (strtotime(date('H:i', $start_time)) >= strtotime('8am') && strtotime(date('H:i', $start_time)) <= strtotime('4pm')) //8am to 4pm | |
{ | |
$weekdays_price = 420; //set price here for time between 8am to 4pm for all weekdays | |
} | |
elseif (strtotime(date('H:i', $start_time)) > strtotime('4pm') && strtotime(date('H:i', $start_time)) <= strtotime('11pm')) //4pm to 11pm | |
{ | |
$weekdays_price = 430; //set price here for time between 4pm to 11pm for all weekdays | |
} | |
elseif (strtotime(date('H:i', $start_time)) > strtotime('11pm') || strtotime(date('H:i', $start_time)) < strtotime('8am')) //11pm to 8am | |
{ | |
$weekdays_price = 440; //set price here for time between 11pm to 8am for all weekdays | |
} | |
$weekends_price = 500; //price for weekends(Saturday and Sunday) | |
$day = date('N', $start_time); | |
if($day>0 && $day<6) | |
{ | |
$price = $weekdays_price; | |
} | |
else if ($day==6 || $day==7) | |
{ | |
$price = $weekends_price; | |
} | |
$send_time_and_cost = ''.$start_time_wp_format.'</span><br><span id="show_cost_below_time">'.$currency.$price.''; | |
return $send_time_and_cost; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment