WordPress at Your Fingertips
function is not described


Checkout::add_data_to_error_object() private WC 1.0

Adds additional data to the \WP_Error object.

{} It's a method of the class: Checkout{}

No Hooks.


null. Nothing.


// 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.
Whether the cart should be included in the error data.
Default: false

Code of Checkout::add_data_to_error_object() WC 5.8.0

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()->api->get_endpoint_data( '/wc/store/cart' ) ] );
	$error->add_data( $data );
	return $error;