WordPress at Your Fingertips
function is not described

wc_add_order_item() WC 1.0

Add a item to an order (for example a line item).

Hooks from the function
Return

Int|true|false. Item ID or false

Usage

wc_add_order_item( $order_id, $item_array );
$order_id(int) (required)
Order ID.
$item_array(array) (required)
Items list.

Code of wc_add_order_item() WC 5.6.0

function wc_add_order_item( $order_id, $item_array ) {
	$order_id = absint( $order_id );

	if ( ! $order_id ) {
		return false;
	}

	$defaults = array(
		'order_item_name' => '',
		'order_item_type' => 'line_item',
	);

	$item_array = wp_parse_args( $item_array, $defaults );
	$data_store = WC_Data_Store::load( 'order-item' );
	$item_id    = $data_store->add_order_item( $order_id, $item_array );
	$item       = WC_Order_Factory::get_order_item( $item_id );

	do_action( 'woocommerce_new_order_item', $item_id, $item, $order_id );

	return $item_id;
}