WordPress at Your Fingertips
function is not described

WC_Order_Item_Data_Store::delete_order_item() public WC 3.0.0

Delete an order item.

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

No Hooks.

Return

null. Nothing.

Usage

$WC_Order_Item_Data_Store = new WC_Order_Item_Data_Store();
$WC_Order_Item_Data_Store->delete_order_item( $item_id );
$item_id(int) (required)
Item ID.

Changelog

Since 3.0.0 Introduced.

Code of WC_Order_Item_Data_Store::delete_order_item() WC 5.7.1

public function delete_order_item( $item_id ) {
	// Load the order ID before the deletion, since after, it won't exist in the database.
	$order_id = $this->get_order_id_by_order_item_id( $item_id );

	global $wpdb;
	$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_id = %d", $item_id ) );
	$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE order_item_id = %d", $item_id ) );

	$this->clear_caches( $item_id, $order_id );
}