Automattic\WooCommerce\StoreApi\Utilities
CartController::get_cart_errors
Validate the cart and get a list of errors.
Method of the class: CartController{}
No Hooks.
Returns
WP_Error. A WP_Error instance containing the cart's errors.
Usage
$CartController = new CartController(); $CartController->get_cart_errors();
CartController::get_cart_errors() CartController::get cart errors code WC 10.7.0
public function get_cart_errors() {
$errors = new WP_Error();
try {
$this->validate_cart();
} catch ( RouteException $error ) {
$errors->add( $error->getErrorCode(), $error->getMessage(), $error->getAdditionalData() );
} catch ( InvalidCartException $error ) {
$errors->merge_from( $error->getError() );
} catch ( \Exception $error ) {
$errors->add( $error->getCode(), $error->getMessage() );
}
return $errors;
}