WooCommerce Code Reference

WC_API extends WC_Legacy_API
in package

WC_API class.

Table of Contents

VERSION  = '3.1.0'
This is the major version for the REST API and takes first-order position in endpoint URLs.
$authentication  : WC_API_Authentication
REST API authentication class instance.
$server  : WC_API_Server
The REST API server.
add_endpoint()  : mixed
WC API for payment gateway IPNs, etc.
add_query_vars()  : string[]
Add new query vars.
get_endpoint_data()  : array|WP_Error
Get data from a WooCommerce API endpoint.
get_rest_api_package_path()  : string
Get the version of the REST API package being ran.
get_rest_api_package_version()  : string|null
Get the version of the REST API package being ran. Since API package was merged into core, this now follows WC version.
handle_api_requests()  : mixed
API request - Trigger any API requests.
handle_rest_api_requests()  : mixed
Handle REST API requests.
includes()  : mixed
Include required files for REST API request.
init()  : mixed
Init the API by setting up action and filter hooks.
register_resources()  : mixed
Register available API resources.
register_rest_routes()  : mixed
Register REST API routes.
register_wp_admin_settings()  : mixed
Register WC settings from WP-API to the REST API.
rest_api_includes()  : mixed
Include REST API classes.
rest_api_init()  : mixed
Rest API Init.
is_rest_api_loaded()  : bool
Return if the rest API classes were already loaded.
handle_v1_rest_api_request()  : mixed
Handle legacy v1 REST API requests.
handle_v2_rest_api_request()  : mixed
Handle legacy v2 REST API requests.

Constants

VERSION

This is the major version for the REST API and takes first-order position in endpoint URLs.

public string VERSION = '3.1.0'
Tags
deprecated
2.6.0

Properties

Methods

add_endpoint()

WC API for payment gateway IPNs, etc.

public static add_endpoint() : mixed
Tags
since
2.0
Return values
mixed

add_query_vars()

Add new query vars.

public add_query_vars(array $vars) : string[]
Parameters
$vars : array

Query vars.

Tags
since
2.0
Return values
string[]

get_endpoint_data()

Get data from a WooCommerce API endpoint.

public get_endpoint_data(string $endpoint[, array $params = array() ]) : array|WP_Error
Parameters
$endpoint : string

Endpoint.

$params : array = array()

Params to passwith request.

Tags
since
3.7.0
Return values
array|WP_Error

get_rest_api_package_path()

Get the version of the REST API package being ran.

public get_rest_api_package_path() : string
Tags
since
3.7.0
Return values
string

get_rest_api_package_version()

Get the version of the REST API package being ran. Since API package was merged into core, this now follows WC version.

public get_rest_api_package_version() : string|null
Tags
since
3.7.0
Return values
string|null

handle_api_requests()

API request - Trigger any API requests.

public handle_api_requests() : mixed
Tags
since
2.0
version
2.4
Return values
mixed

init()

Init the API by setting up action and filter hooks.

public init() : mixed
Return values
mixed

register_resources()

Register available API resources.

public register_resources(WC_API_Server $server) : mixed
Parameters
$server : WC_API_Server

the REST server.

Tags
since
2.1
deprecated
2.6.0
Return values
mixed

register_wp_admin_settings()

Register WC settings from WP-API to the REST API.

public register_wp_admin_settings() : mixed
Tags
since
3.0.0
Return values
mixed

rest_api_includes()

Include REST API classes.

public rest_api_includes() : mixed
Tags
deprecated
3.7.0
  • REST API clases autoload.
Return values
mixed

is_rest_api_loaded()

Return if the rest API classes were already loaded.

protected is_rest_api_loaded() : bool
Tags
since
3.7.0
Return values
bool

handle_v1_rest_api_request()

Handle legacy v1 REST API requests.

private handle_v1_rest_api_request() : mixed
Tags
since
2.2
deprecated
2.6.0
Return values
mixed

handle_v2_rest_api_request()

Handle legacy v2 REST API requests.

private handle_v2_rest_api_request() : mixed
Tags
since
2.4
deprecated
2.6.0
Return values
mixed