wc_update_order_item

Update an item for an order.

Description

wc_update_order_item( (int) $item_id, (array) $args ); 

Parameters (2)

0. $item_id (int)
The item id.
1. $args (array)
Either order_item_type or order_item_name

Usage

  1. if ( !function_exists( 'wc_update_order_item' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-order-item-functions.php'; 
  3.  
  4. // The item id. 
  5. $item_id = -1; 
  6.  
  7. // either `order_item_type` or `order_item_name` 
  8. $args = array(); 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wc_update_order_item($item_id, $args); 
  12.  

Defined (1)

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

/includes/wc-order-item-functions.php  
  1. function wc_update_order_item( $item_id, $args ) { 
  2. $data_store = WC_Data_Store::load( 'order-item' ); 
  3. $update = $data_store->update_order_item( $item_id, $args ); 
  4.  
  5. if ( false === $update ) { 
  6. return false; 
  7.  
  8. do_action( 'woocommerce_update_order_item', $item_id, $args ); 
  9.  
  10. return true;