WooCommerce Code Reference

WC_Order_Item_Meta
in package

Order item meta class.

Table of Contents

$meta  : array<string|int, mixed>|null
Post meta data
$product  : WC_Product|null
Product object.
$item  : array<string|int, mixed>|null
Order item
$legacy  : bool
For handling backwards compatibility.
__construct()  : mixed
Constructor.
display()  : string|void
Display meta in a formatted list.
get_formatted()  : array<string|int, mixed>
Return an array of formatted item meta in format e.g.
get_formatted_legacy()  : array<string|int, mixed>
Return an array of formatted item meta in format e.g.

Properties

Methods

__construct()

Constructor.

public __construct([array<string|int, mixed> $item = array() ][, WC_Product $product = null ]) : mixed
Parameters
$item : array<string|int, mixed> = array()

defaults to array().

$product : WC_Product = null

defaults to null.

Return values
mixed

display()

Display meta in a formatted list.

public display([bool $flat = false ][, bool $return = false ][, string $hideprefix = '_' ][, string $delimiter = ", " ]) : string|void
Parameters
$flat : bool = false

Flat (default: false).

$return : bool = false

Return (default: false).

$hideprefix : string = '_'

Hide prefix (default: _).

$delimiter : string = ", "

Delimiter used to separate items when $flat is true.

Return values
string|void

get_formatted()

Return an array of formatted item meta in format e.g.

public get_formatted([string $hideprefix = '_' ]) : array<string|int, mixed>

Returns: array( 'pa_size' => array( 'label' => 'Size', 'value' => 'Medium', ) )

Parameters
$hideprefix : string = '_'

exclude meta when key is prefixed with this, defaults to '_'.

Tags
since
2.4
Return values
array<string|int, mixed>

get_formatted_legacy()

Return an array of formatted item meta in format e.g.

public get_formatted_legacy([string $hideprefix = '_' ]) : array<string|int, mixed>

Handles @deprecated args.

Parameters
$hideprefix : string = '_'

Hide prefix.

Return values
array<string|int, mixed>