WC_Order_Item_Shipping_Data_Store

WC Order Item Shipping Data Store.

Defined (1)

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

/includes/data-stores/class-wc-order-item-shipping-data-store.php  
  1. class WC_Order_Item_Shipping_Data_Store extends Abstract_WC_Order_Item_Type_Data_Store implements WC_Object_Data_Store_Interface, WC_Order_Item_Type_Data_Store_Interface { 
  2.  
  3. /** 
  4. * Data stored in meta keys. 
  5. * @since 3.0.0 
  6. * @var array 
  7. */ 
  8. protected $internal_meta_keys = array( 'method_id', 'cost', 'total_tax', 'taxes' ); 
  9.  
  10. /** 
  11. * Read/populate data properties specific to this order item. 
  12. * @since 3.0.0 
  13. * @param WC_Order_Item_Shipping $item 
  14. */ 
  15. public function read( &$item ) { 
  16. parent::read( $item ); 
  17. $id = $item->get_id(); 
  18. $item->set_props( array( 
  19. 'method_id' => get_metadata( 'order_item', $id, 'method_id', true ),  
  20. 'total' => get_metadata( 'order_item', $id, 'cost', true ),  
  21. 'taxes' => get_metadata( 'order_item', $id, 'taxes', true ),  
  22. ) ); 
  23. $item->set_object_read( true ); 
  24.  
  25. /** 
  26. * Saves an item's data to the database / item meta. 
  27. * Ran after both create and update, so $id will be set. 
  28. * @since 3.0.0 
  29. * @param WC_Order_Item_Shipping $item 
  30. */ 
  31. public function save_item_data( &$item ) { 
  32. $id = $item->get_id(); 
  33. $save_values = array( 
  34. 'method_id' => $item->get_method_id( 'edit' ),  
  35. 'cost' => $item->get_total( 'edit' ),  
  36. 'total_tax' => $item->get_total_tax( 'edit' ),  
  37. 'taxes' => $item->get_taxes( 'edit' ),  
  38. ); 
  39. foreach ( $save_values as $key => $value ) { 
  40. update_metadata( 'order_item', $id, $key, $value );