Skip to content
Docs
Get RestroPress

Filter

rpress_current_service_type

Updated
On this page

Filters the current service type (delivery, pickup and similar).

Applied to the service type that the storefront considers active. In the frontend script setup the value comes from the service_type cookie, or the default enabled service when there is no cookie. In the service context builder the value has already been validated against the enabled services. Extensions can use this to force or remap the service type.

Parameters#

ParameterTypeDescription
$service_typestringService type slug, for example delivery or pickup.

Return value#

string. The service type slug.

Example#

function my_current_service_type( $service_type ) {
	// Force pickup on a dedicated landing page.
	if ( is_page( 'pickup-only' ) ) {
		return 'pickup';
	}
	return $service_type;
}
add_filter( 'rpress_current_service_type', 'my_current_service_type' );

Notes#

Fired from RP_Frontend_Scripts::load_scripts() (cookie value, unvalidated) and rpress_get_service_context() (validated value). Both pass one argument.

Source#

Applied in:

  • includes/class-rpress-frontend-scripts.php (line 400), in RP_Frontend_Scripts::load_scripts()
  • includes/rp-core-functions.php (line 3075), in rpress_get_service_context()

See also#

Was this page helpful?