Cart_Route extends Base_Route implements Route

REST controller for the cart route.

Tags
author

Barn2 Plugins support@barn2.com

license

GPL-3.0

copyright

Barn2 Media Ltd

Interfaces, Classes and Traits

Route

Table of Contents

$cart_quantity  : mixed
$rest_base  : mixed
add_product()  : mixed
cart_quantity()  : mixed
Cart quantity route callback.
register_routes()  : mixed
add_product_to_cart()  : mixed
check_prerequisites()  : mixed
Check any prerequisites required for our add to cart request.
filter_quantity()  : mixed
get_add_to_cart_fragments()  : mixed
get_add_to_cart_hash()  : mixed
get_error_message()  : mixed
get_product_names()  : string
Get the list of product names from the passed array of products [ product ID => quantity ].
get_submitted_variations()  : mixed
is_product_sold_individually()  : bool
Check if the product is sold individually.
validate_add_item_params()  : WP_Error|array<string|int, mixed>
Validate the params for this REST request.

Properties

$cart_quantity

protected mixed $cart_quantity = 'cart-quantity'

Methods

add_product()

public add_product(mixed $request) : mixed
Parameters
$request : mixed
Return values
mixed

cart_quantity()

Cart quantity route callback.

public cart_quantity(mixed $request) : mixed
Parameters
$request : mixed
Return values
mixed

register_routes()

public register_routes() : mixed
Return values
mixed

add_product_to_cart()

protected add_product_to_cart(array<string|int, mixed> $params) : mixed
Parameters
$params : array<string|int, mixed>
Return values
mixed

check_prerequisites()

Check any prerequisites required for our add to cart request.

protected check_prerequisites() : mixed
Return values
mixed

filter_quantity()

protected filter_quantity(mixed $qty) : mixed
Parameters
$qty : mixed
Return values
mixed

get_add_to_cart_fragments()

protected get_add_to_cart_fragments() : mixed
Return values
mixed

get_add_to_cart_hash()

protected get_add_to_cart_hash() : mixed
Return values
mixed

get_error_message()

protected get_error_message() : mixed
Return values
mixed

get_product_names()

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

protected get_product_names(array<string|int, mixed> $products[, mixed $include_quantity = false ][, mixed $name_in_quotes = true ]) : string
Parameters
$products : array<string|int, mixed>

An array of products IDs mapped to the quantity added.

$include_quantity : mixed = false
$name_in_quotes : mixed = true
Return values
string

The formatted product names.

get_submitted_variations()

protected get_submitted_variations(mixed $params, WC_Product $product) : mixed
Parameters
$params : mixed
$product : WC_Product
Return values
mixed

is_product_sold_individually()

Check if the product is sold individually.

protected is_product_sold_individually(array<string|int, mixed> $params) : bool
Parameters
$params : array<string|int, mixed>

The request params.

Return values
bool

validate_add_item_params()

Validate the params for this REST request.

protected validate_add_item_params(array<string|int, mixed> $params) : WP_Error|array<string|int, mixed>
Parameters
$params : array<string|int, mixed>

The params to validate.

Return values
WP_Error|array<string|int, mixed>
  • The validated params or a WP_Error if the product is not valid.

Search results