Skip to content
Docs
Get RestroPress

Filter

rpress_check_service_slot

Updated
On this page

Filters the result of the service type and time slot validation request.

Runs in RP_AJAX::check_service_slot() with the sanitized POST data of the service popup. The result then passes through rpress_validate_slot. A WP_Error is returned to the client as an error message, an array is returned as is, and any other value is treated as success if it is not empty. The cart totals are merged into the response afterwards.

Parameters#

ParameterTypeDescription
$dataarraySanitized POST data of the service selection request.

Return value#

array|WP_Error|mixed. The response data, a WP_Error to reject the selection, or a truthy or empty value.

Example#

function my_check_service_slot( $data ) {
	if ( isset( $data['serviceType'] ) && 'delivery' === $data['serviceType'] && gmdate( 'G' ) >= 22 ) {
		return new WP_Error( 'closed', __( 'Delivery is closed for the night.', 'my-textdomain' ) );
	}
	return $data;
}
add_filter( 'rpress_check_service_slot', 'my_check_service_slot', 10, 1 );

Notes#

The array keys of $data depend on what the front-end script posts; the example reads serviceType, which the built-in flat delivery fee callback (priority 9) also reads. That callback skips its work when an earlier filter returned a WP_Error.

Source#

Applied in:

  • includes/class-rpress-ajax.php (line 819), in RP_AJAX::check_service_slot()

See also#

Was this page helpful?