wc_get_order_id_by_order_item_id

Get order ID by order item ID.

Description

(int) wc_get_order_id_by_order_item_id( (int) $item_id ); 

Returns (int)

Parameters (1)

0. $item_id (int)
The item id.

Usage

  1. if ( !function_exists( 'wc_get_order_id_by_order_item_id' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-order-item-functions.php'; 
  3.  
  4. // The item id. 
  5. $item_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_get_order_id_by_order_item_id($item_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-order-item-functions.php  
  1. function wc_get_order_id_by_order_item_id( $item_id ) { 
  2. $data_store = WC_Data_Store::load( 'order-item' ); 
  3. return $data_store->get_order_id_by_order_item_id( $item_id );