Automattic\WooCommerce\StoreApi\Schemas\V1
CartSchema::get_cart_errors()
Get cart validation errors.
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.
CartSchema::get_cart_errors() CartSchema::get cart errors code WC 7.7.0
protected function get_cart_errors( $cart ) { $controller = new CartController(); $errors = $controller->get_cart_errors(); $cart_errors = []; foreach ( (array) $errors->errors as $code => $messages ) { foreach ( (array) $messages as $message ) { $cart_errors[] = new \WP_Error( $code, $message, $errors->get_error_data( $code ) ); } } return array_values( array_map( [ $this->error_schema, 'get_item_response' ], $cart_errors ) ); }