WordPress at Your Fingertips
function is not described

wc_add_order_item_meta() WC 1.0

WooCommerce Order Item Meta API - Add term meta.

No Hooks.


Int. New row ID or 0.


wc_add_order_item_meta( $item_id, $meta_key, $meta_value, $unique );
$item_id(int) (required)
Item ID.
$meta_key(string) (required)
Meta key.
$meta_value(string) (required)
Meta value.
If meta data should be unique (default: false).
Default: false

Code of wc_add_order_item_meta() WC 5.8.0

function wc_add_order_item_meta( $item_id, $meta_key, $meta_value, $unique = false ) {
	$data_store = WC_Data_Store::load( 'order-item' );
	$meta_id    = $data_store->add_metadata( $item_id, $meta_key, $meta_value, $unique );

	if ( $meta_id ) {
		WC_Cache_Helper::invalidate_cache_group( 'object_' . $item_id ); // Invalidate cache.
		return $meta_id;
	return 0;