Cart_Controller
- Full name:
\BigCommerce\Rest\Cart_Controller - Parent class:
\BigCommerce\Rest\Rest_Controller
Methods
__construct
Rest_Controller constructor.
public __construct(mixed $namespace_base, mixed $version, mixed $rest_base, \BigCommerce\Api\v3\Api\CartApi $cart_api): mixedParameters:
| Parameter | Type | Description |
|---|---|---|
$namespace_base | mixed | |
$version | mixed | |
$rest_base | mixed | |
$cart_api | \BigCommerce\Api\v3\Api\CartApi |
js_config
Add data to the JS config to support cart ajax
public js_config(array $config): arrayParameters:
| Parameter | Type | Description |
|---|---|---|
$config | array |
register_routes
public register_routes(): mixedget_items
public get_items(\WP_REST_Request $request): \WP_Error|\WP_REST_ResponseParameters:
| Parameter | Type | Description |
|---|---|---|
$request | \WP_REST_Request | Full data about the request. |
Return Value:
Response object on success, or WP_Error object on failure.
prepare_item_for_response
Prepares a cart for response.
public prepare_item_for_response(\BigCommerce\Api\v3\Model\Cart $cart, \WP_REST_Request $request): \WP_REST_ResponseParameters:
| Parameter | Type | Description |
|---|---|---|
$cart | \BigCommerce\Api\v3\Model\Cart | Cart object. |
$request | \WP_REST_Request | Request object. |
Return Value:
Response object.
create_cart_permissions_check
public create_cart_permissions_check(mixed $request): mixedParameters:
| Parameter | Type | Description |
|---|---|---|
$request | mixed |
cart_id_access_check
Checks that the user’s cart cookie matches the cart in the request
public cart_id_access_check(\WP_REST_Request $request): boolParameters:
| Parameter | Type | Description |
|---|---|---|
$request | \WP_REST_Request |
create_cart
Creates the cart with an item in it
public create_cart(\WP_REST_Request $request): \WP_Error|\WP_REST_ResponseParameters:
| Parameter | Type | Description |
|---|---|---|
$request | \WP_REST_Request | Full data about the request. |
Return Value:
Response object on success, or WP_Error object on failure.
create_item
Adds an item to the cart.
public create_item(\WP_REST_Request $request): \WP_Error|\WP_REST_ResponseParameters:
| Parameter | Type | Description |
|---|---|---|
$request | \WP_REST_Request | Full data about the request. |
Return Value:
Response object on success, or WP_Error object on failure.
create_postable_line_item
protected create_postable_line_item(\WP_REST_Request $request): mixedParameters:
| Parameter | Type | Description |
|---|---|---|
$request | \WP_REST_Request |
delete_item
Deletes one item from the cart.
public delete_item(\WP_REST_Request $request): \WP_Error|\WP_REST_ResponseParameters:
| Parameter | Type | Description |
|---|---|---|
$request | \WP_REST_Request | Full data about the request. |
Return Value:
Response object on success, or WP_Error object on failure.
update_item
Updates one item from the cart.
public update_item(\WP_REST_Request $request): \WP_Error|\WP_REST_ResponseParameters:
| Parameter | Type | Description |
|---|---|---|
$request | \WP_REST_Request | Full data about the request. |
Return Value:
Response object on success, or WP_Error object on failure.
get_cart_item
Get the item, if the ID is valid.
protected get_cart_item(string $cart_id, string $item_id): \BigCommerce\Api\v3\Model\BaseItem|\WP_ErrorParameters:
| Parameter | Type | Description |
|---|---|---|
$cart_id | string | |
$item_id | string |
Return Value:
Term object if ID is valid, WP_Error otherwise.
get_cart_data
protected get_cart_data(mixed $cart_id): \BigCommerce\Api\v3\Model\CartParameters:
| Parameter | Type | Description |
|---|---|---|
$cart_id | mixed |
Throws:
get_item_schema
Retrieves the response’s schema, conforming to JSON Schema.
public get_item_schema(): arrayReturn Value:
Item schema data.
get_mini_cart
Render the current user’s mini-cart, and return as a rest response object
public get_mini_cart(): \WP_REST_Responseget_rendered_item_schema
public get_rendered_item_schema(): mixedInherited methods
__construct
Rest_Controller constructor.
public __construct(string $namespace_base, string $version, string $rest_base): mixedParameters:
| Parameter | Type | Description |
|---|---|---|
$namespace_base | string | |
$version | string | |
$rest_base | string |
get_namespace
protected get_namespace(): mixedget_base_url
public get_base_url(): mixedparse_result
protected parse_result(mixed $response, mixed $client, mixed $rest_response = true): mixedParameters:
| Parameter | Type | Description |
|---|---|---|
$response | mixed | |
$client | mixed | |
$rest_response | mixed |
Automatically generated on 2025-01-21