WordPress at Your Fingertips
function is not described

Abstract_WC_Order_Item_Type_Data_Store::create() public WC 3.0.0

Create a new order item in the database.

{} It's a method of the class: Abstract_WC_Order_Item_Type_Data_Store{}

Hooks from the method

Return

null. Nothing.

Usage

$Abstract_WC_Order_Item_Type_Data_Store = new Abstract_WC_Order_Item_Type_Data_Store();
$Abstract_WC_Order_Item_Type_Data_Store->create( $item );
$item(WC_Order_Item) (required) (passed by reference — &)
Order item object.

Changelog

Since 3.0.0 Introduced.

Code of Abstract_WC_Order_Item_Type_Data_Store::create() WC 5.8.0

public function create( &$item ) {
	global $wpdb;

	$wpdb->insert(
		$wpdb->prefix . 'woocommerce_order_items',
		array(
			'order_item_name' => $item->get_name(),
			'order_item_type' => $item->get_type(),
			'order_id'        => $item->get_order_id(),
		)
	);
	$item->set_id( $wpdb->insert_id );
	$this->save_item_data( $item );
	$item->save_meta_data();
	$item->apply_changes();
	$this->clear_cache( $item );

	do_action( 'woocommerce_new_order_item', $item->get_id(), $item, $item->get_order_id() );
}