WC_Order_Item_Data_Store::get_order_id_by_order_item_id()publicWC 3.0.0

Get order ID by order item ID.

Method of the class: WC_Order_Item_Data_Store{}

No Hooks.

Return

Int.

Usage

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

Changelog

Since 3.0.0 Introduced.

WC_Order_Item_Data_Store::get_order_id_by_order_item_id() code WC 9.4.2

public function get_order_id_by_order_item_id( $item_id ) {
	global $wpdb;
	return (int) $wpdb->get_var(
		$wpdb->prepare(
			"SELECT order_id FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_id = %d",
			$item_id
		)
	);
}