WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Blocks\StoreApi\Schemas

CartSchema::get_cart_errors() protected WC 1.0

Get cart validation errors.

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

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_cart_errors( $cart );
$cart(\WC_Cart) (required)
Cart class instance.

Code of CartSchema::get_cart_errors() WC 5.8.0

protected function get_cart_errors( $cart ) {
	$controller    = new CartController();
	$item_errors   = array_filter(
		$controller->get_cart_item_errors(),
		function ( WP_Error $error ) {
			return $error->has_errors();
		}
	);
	$coupon_errors = $controller->get_cart_coupon_errors();

	return array_values( array_map( [ $this->error_schema, 'get_item_response' ], array_merge( $item_errors, $coupon_errors ) ) );
}