Automattic\WooCommerce\StoreApi\Utilities

CartController::get_cart_errors()publicWC 1.0

Validate the cart and get a list of errors.

{} Это метод класса: CartController{}

Хуков нет.

Возвращает

WP_Error. A WP_Error instance containing the cart's errors.

Использование

$CartController = new CartController();
$CartController->get_cart_errors();

Код CartController::get_cart_errors() WC 6.8.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;
}