Displaying certain php files based on store open hours using If/Else statement


#1

I am currently implementing an online ordering system for a restaurant and have 2 sections to display a mini-cart on the website and store open hours.

Currently both of them show together on the website. However, I would like to have an if/else to show the mini cart during open hours only rather than all the time (as it will restrict orders from being taken out of hours). Out of hours it will show the store open hours and will hide the mini cart.

Currently I have the following code I have attempted to display this, however I keep getting syntax errors on the last line.

<?php

//code for showing minicart during open hours

// Gets current day of week
$status_today = strtolower(date(“D”));
// Gets current time of day in 00:00 format
$current_time = date(“G:i”);
// Makes current time of day computer-readable
$current_time_x = strtotime($current_time);

// Builds an array, assigning user-defined time ranges to each day of week
$all_days = array(“mon” => $time_range_mon, “tue” => $time_range_tue, “wed” => $time_range_wed, “thu” => $time_range_thu, “fri” => $time_range_fri, “Sat” => $time_range_sat, “sun” => $time_range_sun);
foreach ($all_days as &$each_day) {
$each_day = explode("-", $each_day);
$each_day[0] = strtotime($each_day[0]);
$each_day[1] = strtotime($each_day[1]);
}

// Defines array of possible days of week
$week_days = array(“mon”, “tue”, “wed”, “thu”, “fri”, “sat”, “sun”);

if ($status_today == $each_week_day) {
echo ‘

’;
if (($all_days[$each_week_day][0] <= $current_time_x) && ($all_days[$each_week_day][1] >= $current_time_x)) {
require_once ‘include/miniCart.php’;
} else {
include ‘include/openHours.php’;
}
?>

 

<?php require_once 'include/footer.php'; ?>