ClassesBigCommerceRestCart Controller

Cart_Controller

Methods

__construct

Rest_Controller constructor.

public __construct(mixed $namespace_base, mixed $version, mixed $rest_base, \BigCommerce\Api\v3\Api\CartApi $cart_api): mixed

Parameters:

ParameterTypeDescription
$namespace_basemixed
$versionmixed
$rest_basemixed
$cart_api\BigCommerce\Api\v3\Api\CartApi

js_config

Add data to the JS config to support cart ajax

public js_config(array $config): array

Parameters:

ParameterTypeDescription
$configarray

register_routes

public register_routes(): mixed

get_items

public get_items(\WP_REST_Request $request): \WP_Error|\WP_REST_Response

Parameters:

ParameterTypeDescription
$request\WP_REST_RequestFull 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_Response

Parameters:

ParameterTypeDescription
$cart\BigCommerce\Api\v3\Model\CartCart object.
$request\WP_REST_RequestRequest object.

Return Value:

Response object.


create_cart_permissions_check

public create_cart_permissions_check(mixed $request): mixed

Parameters:

ParameterTypeDescription
$requestmixed

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): bool

Parameters:

ParameterTypeDescription
$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_Response

Parameters:

ParameterTypeDescription
$request\WP_REST_RequestFull 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_Response

Parameters:

ParameterTypeDescription
$request\WP_REST_RequestFull 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): mixed

Parameters:

ParameterTypeDescription
$request\WP_REST_Request

delete_item

Deletes one item from the cart.

public delete_item(\WP_REST_Request $request): \WP_Error|\WP_REST_Response

Parameters:

ParameterTypeDescription
$request\WP_REST_RequestFull 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_Response

Parameters:

ParameterTypeDescription
$request\WP_REST_RequestFull 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_Error

Parameters:

ParameterTypeDescription
$cart_idstring
$item_idstring

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\Cart

Parameters:

ParameterTypeDescription
$cart_idmixed

Throws:


get_item_schema

Retrieves the response’s schema, conforming to JSON Schema.

public get_item_schema(): array

Return 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_Response

get_rendered_item_schema

public get_rendered_item_schema(): mixed

Inherited methods

__construct

Rest_Controller constructor.

public __construct(string $namespace_base, string $version, string $rest_base): mixed

Parameters:

ParameterTypeDescription
$namespace_basestring
$versionstring
$rest_basestring

get_namespace

protected get_namespace(): mixed

get_base_url

public get_base_url(): mixed

parse_result

protected parse_result(mixed $response, mixed $client, mixed $rest_response = true): mixed

Parameters:

ParameterTypeDescription
$responsemixed
$clientmixed
$rest_responsemixed


Automatically generated on 2025-01-21