Documentation
for Business Hours WP

Welcome to the "Business Hours WP" software documentation. This detailed guide provides a step-by-step walkthrough, helping you navigate and harness the full potential of our software. Whether you're a newcomer or an experienced user, you'll find all the information you need to optimize your experience and effectively manage your business hours conditions in Oxygen or Bricks Builder.

Description

Function within_business_hours() to check if current date/time is within business hours.

Returns true if within business hours. Business hours are defined via two ACF Repeaters. First repeater defines regular business hours per weekday.
Second Repeater defines exceptions to those regular business hours for holidays. Holidays can be defined as a date only (closed all day) or individual business hours for that day.

Import

The package contains three files:

ContentFilenameImport To
1) ACF field group configurationacf-export-business_hours.jsonACF Pro (Advanced Custom Fields Pro)
2) ACF Options Page configurationacf-options-page.code-snippets.jsonCode Snippets (or other PHP Snippet Plugin)
3) Function within_business_hours()business-hours.code-snippets.jsonCode Snippets (or other PHP Snippet Plugin)

Import those files to ACF resp. Code Snippets (or Alternative) in the listed order.

ACF Configuration

The ACF fields can be added to an options page (ACF Pro) or to a single post (ACF free). ACF location is configured with $acf_location.
The field names for the ACF Repeater can be configured with $acf_weekdays and $acf_holidays.

The Repeater sub field names are hard coded and can't be changed by configuration.

1-acf-repeater

The ACF JSON configuration is part of the delivery.

ACF Repeater Weekdays

Repeater business_hours_weekdays

- weekday
Type: Select
Values:

  • 1 : Montag
  • 2 : Dienstag
  • 3 : Mittwoch
  • 4 : Donnerstag
  • 5 : Freitag
  • 6 : Samstag
  • 0 : Sonntag

Return: Value

- start
Type TimePicker
Return: H:i

- end
Type: Time Picker
Return: H:i

Weekdays are evaluated by number, not by weekday name. Hence, weekday names can betranslated.

weekdaystartend

ACF Repeater Holidays

Repeater business_hours_holidays

- date
Type: DatePicker
Return: Ymd

- start
Type TimePicker
Return: H:i

- end
Type: Time Picker
Return: H:i

datestartend

Defining Business Hours

On your ACF options page you can now define your regular business hours for each weekday, and your deviating opening hours on holidays.

If holiday start and end fields are empty, it's evaluated as "closed". If start and end fields are defined those are evaluated as deviating business hours.

business-hours

Function: within_business_hours

The function evaluates dates and times based on server time, using the timezone defined in WordPress settings.

The function code is part of the delivery as PHP and JSON export (for Code Snippets).

Using Function in an Oxygen Code Block

The function within_business_hours() can be used in a Code Block like this:

<?php
if (function_exists('within_business_hours')):
echo 'We're '.(within_business_hours() ? 'open' : 'closed').'!';
endif;
?>

Using Function in an Oxygen Condition

Dynamic Data > PHP Function Return Value
oxygen condition 1
Positive Condition = OPEN
oxygen condition open
Negative Condition = CLOSED
oxygen condition closed

Using Function in a Bricks Code Element

The function within_business_hours() can be used in a Code Block like this:

<?php
if (function_exists('within_business_hours')):
echo 'We're '.(within_business_hours() ? 'open' : 'closed').'!';
endif;
?>

Using Function in a Bricks Condition

Positive Condition = OPEN
Bricks Builder Condition - Open
Negative Condition = CLOSED
Bricks Builder Condition - Closed