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_CATALOG_SEARCH
Capability served by `POST /catalog/search`.
public
mixed
CAPABILITY_CATALOG_SEARCH
= 'dev.ucp.shopping.catalog.search'
FEATURE_ID
Feature id gating the UCP routes, stored as `woocommerce_feature_ucp_enabled`.
public
mixed
FEATURE_ID
= 'ucp'
VERSION
UCP specification version these routes implement.
public
mixed
VERSION
= '2026-04-08'
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> —is_enabled()
Whether the UCP routes are registered.
public
static is_enabled() : bool
Return values
bool —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,
successorerror.
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.
