WooCommerce Code Reference

WC_Order_Item_Data_Store
in package
implements WC_Order_Item_Data_Store_Interface

WC Order Item Data Store: Misc Order Item Data functions.

Tags
version
3.0.0

Interfaces, Classes and Traits

WC_Order_Item_Data_Store_Interface
WC Order Item Data Store Interface

Table of Contents

add_metadata()  : int
Add term meta.
add_order_item()  : int
Add an order item to an order.
delete_metadata()  : bool
Delete term meta.
delete_order_item()  : mixed
Delete an order item.
get_metadata()  : mixed
Get term meta.
get_order_id_by_order_item_id()  : int
Get order ID by order item ID.
get_order_item_type()  : string|null
Get the order item type based on Item ID.
update_metadata()  : bool
Update term meta.
update_order_item()  : bool
Update an order item.
clear_caches()  : mixed
Clear meta cache.

Methods

add_metadata()

Add term meta.

public add_metadata(int $item_id, string $meta_key, mixed $meta_value[, bool $unique = false ]) : int
Parameters
$item_id : int

Item ID.

$meta_key : string

Meta key.

$meta_value : mixed

Meta value.

$unique : bool = false

(default: false).

Tags
since
3.0.0
Return values
intNew row ID or 0

add_order_item()

Add an order item to an order.

public add_order_item(int $order_id, array<string|int, mixed> $item) : int
Parameters
$order_id : int

Order ID.

$item : array<string|int, mixed>

order_item_name and order_item_type.

Tags
since
3.0.0
Return values
intOrder Item ID

delete_metadata()

Delete term meta.

public delete_metadata(int $item_id, string $meta_key[, mixed $meta_value = '' ][, bool $delete_all = false ]) : bool
Parameters
$item_id : int

Item ID.

$meta_key : string

Meta key.

$meta_value : mixed = ''

(default: '').

$delete_all : bool = false

(default: false).

Tags
since
3.0.0
Return values
bool

get_metadata()

Get term meta.

public get_metadata(int $item_id, string $key[, bool $single = true ]) : mixed
Parameters
$item_id : int

Item ID.

$key : string

Meta key.

$single : bool = true

(default: true).

Tags
since
3.0.0
Return values
mixed

get_order_item_type()

Get the order item type based on Item ID.

public get_order_item_type(int $item_id) : string|null
Parameters
$item_id : int

Item ID.

Tags
since
3.0.0
Return values
string|nullOrder item type or null if no order item entry found.

update_metadata()

Update term meta.

public update_metadata(int $item_id, string $meta_key, mixed $meta_value[, string $prev_value = '' ]) : bool
Parameters
$item_id : int

Item ID.

$meta_key : string

Meta key.

$meta_value : mixed

Meta value.

$prev_value : string = ''

(default: '').

Tags
since
3.0.0
Return values
bool

update_order_item()

Update an order item.

public update_order_item(int $item_id, array<string|int, mixed> $item) : bool
Parameters
$item_id : int

Item ID.

$item : array<string|int, mixed>

order_item_name or order_item_type.

Tags
since
3.0.0
Return values
bool

clear_caches()

Clear meta cache.

protected clear_caches(int $item_id, int|null $order_id) : mixed
Parameters
$item_id : int

Item ID.

$order_id : int|null

Order ID. If not set, it will be loaded using the item ID.

Return values
mixed