Skip to content
Docs
Get RestroPress

Function

Order time slots functions

Updated
On this page

Functions for the order time slot engine that produces ASAP and scheduled times.

7 functions. Each entry shows the signature, parameters, return value and where it is defined. Functions marked internal are hook callbacks, screen renderers and other plumbing that extensions normally do not call.

rpress_service_hours_engine_enabled()#

Checks whether the core open and slot functions route through the RPRESS_Service_Hours engine.

On by default when core basic hours are in charge. When the Store Timing extension owns the schedule the legacy code path runs. Filterable through rpress_use_service_hours_engine; return false to switch the engine off.

rpress_service_hours_engine_enabled()

Returns bool: True when the engine is used.

Example

add_filter( 'rpress_use_service_hours_engine', '__return_false' );

Defined in includes/features/slot-engine/functions.php, line 28.

rpress_service_hours()#

Returns a service hours engine instance for the site timezone.

Creates a new RPRESS_Service_Hours, filterable through rpress_service_hours_instance.

rpress_service_hours()

Returns RPRESS_Service_Hours: The engine instance.

Example

$engine = rpress_service_hours();
$now    = $engine->now();

Defined in includes/features/slot-engine/functions.php, line 39.

rpress_service_hours_time_format()#

Returns the PHP date format used for slot labels.

H:i when store_time_format is 24hrs, h:i A when it is 12hrs, otherwise the WordPress time_format option.

rpress_service_hours_time_format()

Returns string: A date format string.

Example

$format = rpress_service_hours_time_format();

Defined in includes/features/slot-engine/functions.php, line 49.

rpress_service_hours_store_timings()#

Returns the order time slots for a service and date, using the slot engine.

Engine version of rp_get_store_timings() with the same return shape. Returns formatted times, or raw timestamps when the rpress_timing_for_today filter returns false. With hide_past_time set, slots before now plus prep time are dropped; future dates also drop slots before now plus prep.

rpress_service_hours_store_timings( $hide_past_time = true, $service_type = null, $service_date = '' )

Parameters

ParameterTypeDefaultDescription
$hide_past_timebooltrueDrop slots before now plus prep time.
$service_typestring|nullnullService type, for example delivery or pickup.
$service_datestring''Y-m-d date; empty means today.

Returns array: Formatted time strings, or timestamps (int) when rpress_timing_for_today is false.

Example

$slots = rpress_service_hours_store_timings( true, 'pickup', wp_date( 'Y-m-d' ) );

Defined in includes/features/slot-engine/functions.php, line 72.

rpress_service_hours_is_store_open()#

Checks whether the store is open for a service on a date, using the slot engine.

Engine version of rpress_is_store_open() with the same contract and filter arguments. Past dates are closed; a future date is open only when pre-orders are enabled and the date has hours, unless it is the midnight rollover date. The result passes through the rpress_is_store_open filter.

rpress_service_hours_is_store_open( $service_type, $selected_date = '' )

Parameters

ParameterTypeDefaultDescription
$service_typestringRequiredService type.
$selected_datestring''Date being asked about; empty means today.

Returns bool: True when open.

Example

$open = rpress_service_hours_is_store_open( 'delivery' );

Defined in includes/features/slot-engine/functions.php, line 117.

rpress_service_hours_selected_service_date()#

Returns the service date to use for a service, handling past dates, pre-orders and midnight rollover.

Past dates move to today. Future dates are kept only when allow_future is true and pre-orders are enabled, or when the date is the rollover date. When today has no slots left but ordering continues past midnight, tomorrow is returned.

rpress_service_hours_selected_service_date( $service_type, $requested_date = '', $allow_future = true )

Parameters

ParameterTypeDefaultDescription
$service_typestringRequiredService type.
$requested_datestring''Requested date.
$allow_futurebooltrueWhether future dates from cookies are kept.

Returns string: A Y-m-d date.

Example

$date = rpress_service_hours_selected_service_date( 'delivery' );

Defined in includes/features/slot-engine/functions.php, line 166.

rpress_service_hours_closed_message()#

Appends the next available time to the store closed message.

Hooked to rpress_store_closed_message at priority 5. Returns the message unchanged when the engine is off, no next slot exists, or the rpress_service_hours_closed_message_next_open filter returns false.

rpress_service_hours_closed_message( $message, $service_type = '' )

Parameters

ParameterTypeDefaultDescription
$messagestringRequiredClosed message.
$service_typestring''Service type.

Returns string: The message, with Next available text added when known.

Internal. Defined in includes/features/slot-engine/functions.php, line 197.

Was this page helpful?