
Was al enigetijd op zoek om eventueel in de header de openingstijd en winkel gesloten weer te geven,
denk zal hem met jullie delen.. en voor wie hem verder wil ontwikkelen, succes!
wat doet dit script:
Geeft aan:
Geeft aan:Wij zijn open van 13.00 - 18.00 uur
Momenteel zijn wij gesloten.
Stap 1: open een leeg xxxx.php bestand en copy/pasted de onderstaande code regel(s) erin.
Code: Select all
<?php
// -------- PHP STORE CLOSE ---------
// ------- AND OPENINGS HOURS -------
// ---------- Version 1.0.a -----------
// -------- BY Thomas Verheijen -----
// -------- EDIT FOLLOWING SECTION ONLY ---------
// Set your timezone (codes listed at http://php.net/manual/en/timezones.php)
// Delete the following line if you've already defined a timezone elsewhere.
date_default_timezone_set('Europe/Amsterdam');
// Define daily open hours. Must be in 24-hour format, separated by dash.
$time_range_mon = '13.00-23.00'; //Hier start maandag!
$time_range_tue = '09.00-17.00';
$time_range_wed = '09.00-17.00';
$time_range_thu = '09.00-17.00';
$time_range_fri = '09.00-17.00';
$time_range_sat = '09.00-17.00';
$time_range_sun = '00.00-00.00'; //Rust op Zondag!
// Place HTML for output here. Image paths or plain text (H1, H2, p) are all acceptable.
$open_output = '<div class="openings-tijd-open"> Wij zijn open van';
$closed_output = '<div class="openings-tijd-gesloten"> Momenteel zijn wij gesloten';
// OPTIONAL: Output current day's open hours
$echo_daily_hours = true; // Switch to FALSE to hide numerical display of current hours
$time_output = 'H.i'; // Enter custom time output format (options listed here: http://php.net/ looks for....date.php)
$time_separator = ' tot '; // Choose how to indicate range (i.e XX - XX, XX tot XX, XX / XX)
$time_urenend = ' uur';
// -------- END EDITING ------------
// -------- ADD YOUR OWN RISK ------
// Gets current day of week
$status_today = 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");
// Compares current day of week to possible days of week and determines open vs closed output based on current day and time.
foreach ($week_days as &$each_week_day) {
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)) {
echo $open_output;
echo date($time_output, $all_days[$each_week_day][0]) . $time_separator . date($time_output, $all_days[$each_week_day][1]) .$time_urenend;
} else {
echo $closed_output;
}
echo '</div>';
}
}
?>
Bijvoorbeeld: is jouw winkel open op maandag van 08.00 tot 18.00 uur
Code: Select all
$time_range_mon = '08.00-18.00';
Stap 4. Upload het opgeslagen openingstijden.php bestand naar de root enof directory map van je shop.
Stap 5. Plaats de zojuist upgeloaden xxx.php incl. root directory in de onderstaande de code.
bijvoorbeeld: het bestaand is upgeload in directory naam: ..../openingstijd/openingstijden.php
Code: Select all
<?php include 'openingstijd/openingstijden.php'; ?>
voeg eventueel een class container toe, zodat je hem makelijk op z`n plaats kan schuiven.
Code: Select all
<div class="jouwclassytijdenweergave">
<?php include 'openingstijd/openingstijden.php'; ?>
</div>
Code: Select all
.jouwclassytijdenweergave{
background: red;
/*etc....*/
}
.openings-tijd-open{
display: inline;
/*etc....*/
}
.openings-tijd-gesloten{
display: inline;
/*etc....*/
}
./Thomas