wc_update_order_item_meta

WooCommerce Order Item Meta API - Update term meta.

Description

wc_update_order_item_meta( (mixed) $item_id, (mixed) $meta_key, (mixed) $meta_value, (string) $prev_value = '' ); 

Parameters (4)

0. $item_id (mixed)
The item id.
1. $meta_key (mixed)
The meta key.
2. $meta_value (mixed)
The meta value.
3. $prev_value — Optional. (string) => ''
The prev value.

Usage

  1. if ( !function_exists( 'wc_update_order_item_meta' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-order-item-functions.php'; 
  3.  
  4. // The item id. 
  5. $item_id = null; 
  6.  
  7. // The meta key. 
  8. $meta_key = null; 
  9.  
  10. // The meta value. 
  11. $meta_value = null; 
  12.  
  13. // The prev value. 
  14. $prev_value = ''; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = wc_update_order_item_meta($item_id, $meta_key, $meta_value, $prev_value); 
  18.  

Defined (1)

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

/includes/wc-order-item-functions.php  
  1. function wc_update_order_item_meta( $item_id, $meta_key, $meta_value, $prev_value = '' ) { 
  2. $data_store = WC_Data_Store::load( 'order-item' ); 
  3. if ( $data_store->update_metadata( $item_id, $meta_key, $meta_value, $prev_value ) ) { 
  4. $cache_key = WC_Cache_Helper::get_cache_prefix( 'order-items' ) . 'object_meta_' . $item_id; 
  5. wp_cache_delete( $cache_key, 'order-items' ); 
  6. return true; 
  7. return false;