Properties

$rest_base

$rest_base : 

Type

Methods

__construct()

__construct(  $namespace) 

Parameters

$namespace

get_base()

get_base() : string

Get the REST route base which is appended to the namespace (e.g. mybase).

Returns

string —

The REST base.

get_endpoint()

get_endpoint() : string

Get the full endpoint including namespace (e.g. myplugin/v1/mybase).

Returns

string —

The full REST route.

register()

register() 

register_routes()

register_routes() 

add_product()

add_product(\WP_REST_Request  $request) 

Parameters

\WP_REST_Request $request

check_prerequisites()

check_prerequisites() 

Check any prerequisites required for our add to cart request.

validate_params()

validate_params(array  $params) : \WP_Error|array

Valdiate the params for this REST request.

Parameters

array $params

The params to validate.

Returns

\WP_Error|array —
  • The validated params or a WP_Error if the product is not valid.

get_submitted_variations()

get_submitted_variations(  $params, \WC_Product  $product) 

Parameters

$params
\WC_Product $product

add_product_to_cart()

add_product_to_cart(array  $params) 

Parameters

array $params

filter_quantity()

filter_quantity(  $qty) 

Parameters

$qty

get_product_names()

get_product_names(array  $products,   $include_quantity = false,   $name_in_quotes = true) : string

Get the list of product names from the passed array of products [ product ID => quantity ].

Parameters

array $products

An array of products IDs mapped to the quantity added.

$include_quantity
$name_in_quotes

Returns

string —

The formatted product names.

get_add_to_cart_fragments()

get_add_to_cart_fragments() 

get_add_to_cart_hash()

get_add_to_cart_hash() 

get_error_message()

get_error_message()