WooCommerce Code Reference

MessageError extends Message
in package

MessageError class.

Represents a message error object as defined in the Agentic Commerce Protocol. This class handles message-level errors with type, code, content_type, content, and optional param.

Table of Contents

$content  : string
Error content/message.
$content_type  : string
Content type for the error message.
$param  : string|null
RFC 9535 JSONPath to the problematic parameter (optional).
$code  : string
Error code from ErrorCode enum.
$type  : string
The error type (always 'error' for message errors).
__construct()  : mixed
Constructor.
invalid()  : MessageError
Create an invalid field error.
is_error()  : bool
Check if the message is an error.
missing()  : MessageError
Create a missing field error.
out_of_stock()  : MessageError
Create an out of stock error.
payment_declined()  : MessageError
Create a payment declined error.
requires_3ds()  : MessageError
Create a requires 3DS error.
requires_sign_in()  : MessageError
Create a requires sign in error.
to_array()  : array<string|int, mixed>
Convert the error to an array.
use_markdown()  : mixed
Use markdown content type for the content of the error.

Properties

$content_type

Content type for the error message.

protected string $content_type = AutomatticWooCommerceInternalAgenticEnumsSpecsMessageContentType::PLAIN

Defaults to plain, but could also be markdown.

Methods

__construct()

Constructor.

public __construct(string $code, string $content[, string|null $param = null ]) : mixed
Parameters
$code : string

Error code from ErrorCode enum.

$content : string

Error content/message.

$param : string|null = null

RFC 9535 JSONPath (optional).

Return values
mixed