WooCommerce Code Reference

UcpUtils
in package

Shared helpers for the UCP (Universal Commerce Protocol) routes.

Table of Contents

CAPABILITY_CATALOG_LOOKUP  = 'dev.ucp.shopping.catalog.lookup'
Capability served by `POST /catalog/lookup` and `POST /catalog/product`.
CAPABILITY_CATALOG_SEARCH  = 'dev.ucp.shopping.catalog.search'
Capability served by `POST /catalog/search`.
FEATURE_ID  = 'ucp'
Feature id gating the UCP routes, stored as `woocommerce_feature_ucp_enabled`.
VERSION  = '2026-04-08'
UCP specification version these routes implement.
capability_declarations()  : array<string|int, mixed>
Spec and schema references for every capability these routes serve, keyed by capability name.
is_enabled()  : bool
Whether the UCP routes are registered.
response_metadata()  : array<string|int, mixed>
Build the `ucp` envelope every UCP response carries.
capability_declaration()  : array<string|int, mixed>
Spec and schema references for a capability.

Constants

CAPABILITY_CATALOG_LOOKUP

Capability served by `POST /catalog/lookup` and `POST /catalog/product`.

public mixed CAPABILITY_CATALOG_LOOKUP = 'dev.ucp.shopping.catalog.lookup'

Capability served by `POST /catalog/search`.

public mixed CAPABILITY_CATALOG_SEARCH = 'dev.ucp.shopping.catalog.search'

Methods

capability_declarations()

Spec and schema references for every capability these routes serve, keyed by capability name.

public static capability_declarations() : array<string|int, mixed>
Return values
array<string|int, mixed> —

response_metadata()

Build the `ucp` envelope every UCP response carries.

public static response_metadata(string $capability, string $status) : array<string|int, mixed>

UCP requires capabilities to name only the capability relevant to the operation being answered, so each response declares exactly one.

Parameters
$capability : string

One of the CAPABILITY_* constants.

$status : string

Response status, success or error.

Return values
array<string|int, mixed> —

capability_declaration()

Spec and schema references for a capability.

private static capability_declaration(string $capability) : array<string|int, mixed>
Parameters
$capability : string

One of the CAPABILITY_* constants.

Return values
array<string|int, mixed> —