WooCommerce Code Reference

PickupLocationsRestController extends WP_REST_Controller
in package

REST controller for Local Pickup location settings.

Exposes /wc/v3/pickup-locations so users with the manage_woocommerce capability (e.g. Shop Managers) can save Local Pickup settings without requiring the manage_options capability needed by /wp/v2/settings.

Tags
since
11.0.0

Table of Contents

$namespace  : string
REST API namespace.
$rest_base  : string
REST API resource base.
register_routes()  : void
Register routes.
update_settings()  : WP_REST_Response|WP_Error
Save pickup location settings and return the saved values.
update_settings_permissions_check()  : true|WP_Error
Check whether the current user can update pickup location settings.
record_save_event()  : void
Record a Tracks event summarising a Local Pickup settings save.
sanitize_pickup_location_settings()  : array<string|int, mixed>
Sanitize the pickup_location_settings payload before persisting.
sanitize_pickup_locations()  : array<string|int, mixed>
Sanitize the pickup_locations payload before persisting.

Properties

Methods

update_settings()

Save pickup location settings and return the saved values.

public update_settings(WP_REST_Request<string|int, array<string, mixed>> $request) : WP_REST_Response|WP_Error
Parameters
$request : WP_REST_Request<string|int, array<string, mixed>>

Request object.

Return values
WP_REST_Response|WP_Error

update_settings_permissions_check()

Check whether the current user can update pickup location settings.

public update_settings_permissions_check(WP_REST_Request<string|int, array<string, mixed>> $request) : true|WP_Error
Parameters
$request : WP_REST_Request<string|int, array<string, mixed>>

Request object.

Return values
true|WP_Error

record_save_event()

Record a Tracks event summarising a Local Pickup settings save.

private record_save_event(array<string|int, mixed> $settings, array<string|int, mixed> $locations) : void
Parameters
$settings : array<string|int, mixed>

Sanitized method settings.

$locations : array<string|int, mixed>

Sanitized list of pickup locations.

Return values
void

sanitize_pickup_location_settings()

Sanitize the pickup_location_settings payload before persisting.

private sanitize_pickup_location_settings(array<string|int, mixed> $settings) : array<string|int, mixed>

The WP REST dispatcher only auto-sanitizes top-level args, so nested object properties need to be cleaned here as defense in depth against stored HTML/JS in admin surfaces.

Parameters
$settings : array<string|int, mixed>

Raw settings payload.

Return values
array<string|int, mixed>Sanitized settings payload.

sanitize_pickup_locations()

Sanitize the pickup_locations payload before persisting.

private sanitize_pickup_locations(array<string|int, mixed> $locations) : array<string|int, mixed>
Parameters
$locations : array<string|int, mixed>

Raw list of pickup locations.

Return values
array<string|int, mixed>Sanitized list of pickup locations.