Hey there,
after updating from 1.9.9 to 1.10.1 the dynamic tag filter :array_value stopped working.
In my case the tag is {echo:bns_isBusinessOpen:array_value|is_open}
Here is the corresponding code. The returned value always is an array.
function bns_isBusinessOpen() {
// Set the default timezone to Berlin
date_default_timezone_set('Europe/Berlin');
// Get the current day of the week and time
$currentDay = date('N'); // 1 (for Monday) through 7 (for Sunday)
$currentTime = date('H:i');
// Define the opening hours
$openingHours = [
1 => ['10:00', '18:00'], // Monday
2 => ['10:00', '18:00'], // Tuesday
3 => ['10:00', '18:00'], // Wednesday
4 => ['10:00', '21:00'], // Thursday
5 => ['10:00', '18:00'], // Friday
6 => ['12:00', '16:00'], // Saturday
7 => [null, null], // Sunday (closed)
];
// Define the days of the week
$daysOfWeek = [
1 => 'Montag',
2 => 'Dienstag',
3 => 'Mittwoch',
4 => 'Donnerstag',
5 => 'Freitag',
6 => 'Samstag',
7 => 'Sonntag',
];
// Check if today is a closed day
if (is_null($openingHours[$currentDay][0]) || is_null($openingHours[$currentDay][1])) {
return [
'is_open' => false,
'day' => $daysOfWeek[$currentDay],
'hours' => "{$daysOfWeek[$currentDay]} geschlossen"
];
}
// Check if the current time is within the opening hours
$currentTimestamp = strtotime($currentTime);
$openingTime = strtotime($openingHours[$currentDay][0]);
$closingTime = strtotime($openingHours[$currentDay][1]);
// Handle midnight case
if ($closingTime <= $openingTime) {
$closingTime = strtotime('+1 day', $closingTime);
}
$isOpen = ($currentTimestamp >= $openingTime && $currentTimestamp <= $closingTime);
$hoursString = "{$daysOfWeek[$currentDay]}s von " . bnsFormatTime($openingHours[$currentDay][0]) . " - " . bnsFormatTime($openingHours[$currentDay][1]) . " Uhr";
return [
'is_open' => $isOpen,
'day' => $daysOfWeek[$currentDay],
'hours' => $hoursString
];
}
- print_r within the code element correctly display the values.
- the function bns_isBusinessOpen() is whitelisted
Cheers!