Automattic\WooCommerce\StoreApi\Routes\V1
Checkout::add_data_to_error_object()
Adds additional data to the \WP_Error object.
Method of the class: Checkout{}
No Hooks.
Return
null
. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->add_data_to_error_object( $error, $data, $http_status_code, $include_cart );
- $error(\WP_Error) (required)
- The error object to add the cart to.
- $data(array) (required)
- The data to add to the error object.
- $http_status_code(int) (required)
- The HTTP status code this error should return.
- $include_cart(true|false)
- Whether the cart should be included in the error data.
Default: false
Checkout::add_data_to_error_object() Checkout::add data to error object code WC 9.3.3
private function add_data_to_error_object( $error, $data, $http_status_code, bool $include_cart = false ) { $data = array_merge( $data, [ 'status' => $http_status_code ] ); if ( $include_cart ) { $data = array_merge( $data, [ 'cart' => wc_get_container()->get( RestApiUtil::class )->get_endpoint_data( '/wc/store/v1/cart' ) ] ); } $error->add_data( $data ); return $error; }