Automattic\WooCommerce\StoreApi\Routes\V1
Checkout::add_data_to_error_object
Adds additional data to the \WP_Error object.
Метод класса: Checkout{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->add_data_to_error_object( $error, $data, $http_status_code, $include_cart );
- $error(WP_Error) (обязательный)
- The error object to add the cart to.
- $data(массив) (обязательный)
- The data to add to the error object.
- $http_status_code(int) (обязательный)
- The HTTP status code this error should return.
- $include_cart(true|false)
- Whether the cart should be included in the error data.
По умолчанию: false
Код Checkout::add_data_to_error_object() Checkout::add data to error object WC 10.4.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' => $this->cart_schema->get_item_response( $this->cart_controller->get_cart_for_response() ) ] );
}
$error->add_data( $data );
return $error;
}