WooCommerce Code Reference

WC_WCCOM_Site
in package

WC_WCCOM_Site Class

Main class for WooCommerce.com connected site.

Table of Contents

AUTH_ERROR_FILTER_NAME  = 'wccom_auth_error'
authenticate_wccom()  : int|false
Authenticate WooCommerce.com request.
load()  : mixed
Load the WCCOM site class.
register_rest_namespace()  : array
Register wccom-site REST namespace.
get_authorization_header()  : string
Get the authorization header.
includes()  : mixed
Include support files.
is_request_to_wccom_site_rest_api()  : bool
Check if this is a request to WCCOM Site REST API.
verify_wccom_request()  : bool
Verify WooCommerce.com request from a given body and signature request.

Constants

Methods

authenticate_wccom()

Authenticate WooCommerce.com request.

public static authenticate_wccom(int|false $user_id) : int|false
Parameters
$user_id : int|false

User ID.

Tags
since
3.7.0
Return values
int|false

register_rest_namespace()

Register wccom-site REST namespace.

public static register_rest_namespace(array $namespaces) : array
Parameters
$namespaces : array

List of registered namespaces.

Tags
since
3.7.0
Return values
arrayRegistered namespaces.

get_authorization_header()

Get the authorization header.

protected static get_authorization_header() : string

On certain systems and configurations, the Authorization header will be stripped out by the server or PHP. Typically this is then used to generate PHP_AUTH_USER/PHP_AUTH_PASS but not passed on. We use getallheaders here to try and grab it out instead.

Tags
since
3.7.0
Return values
stringAuthorization header if set.

is_request_to_wccom_site_rest_api()

Check if this is a request to WCCOM Site REST API.

protected static is_request_to_wccom_site_rest_api() : bool
Tags
since
3.7.0
Return values
bool

verify_wccom_request()

Verify WooCommerce.com request from a given body and signature request.

protected static verify_wccom_request(string $body, string $signature, string $access_token_secret) : bool
Parameters
$body : string

Request body.

$signature : string

Request signature found in X-Woo-Signature header.

$access_token_secret : string

Access token secret for this site.

Tags
since
3.7.0
Return values
bool