WC_Order_Item_Fee_Data_Store

WC Order Item Fee Data Store.

Defined (1)

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

/includes/data-stores/class-wc-order-item-fee-data-store.php  
  1. class WC_Order_Item_Fee_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( '_tax_class', '_tax_status', '_line_subtotal', '_line_subtotal_tax', '_line_total', '_line_tax', '_line_tax_data' ); 
  9.  
  10. /** 
  11. * Read/populate data properties specific to this order item. 
  12. * @since 3.0.0 
  13. * @param WC_Order_Item_Fee $item 
  14. */ 
  15. public function read( &$item ) { 
  16. parent::read( $item ); 
  17. $id = $item->get_id(); 
  18. $item->set_props( array( 
  19. 'tax_class' => get_metadata( 'order_item', $id, '_tax_class', true ),  
  20. 'tax_status' => get_metadata( 'order_item', $id, '_tax_status', true ),  
  21. 'total' => get_metadata( 'order_item', $id, '_line_total', true ),  
  22. 'taxes' => get_metadata( 'order_item', $id, '_line_tax_data', true ),  
  23. ) ); 
  24. $item->set_object_read( true ); 
  25.  
  26. /** 
  27. * Saves an item's data to the database / item meta. 
  28. * Ran after both create and update, so $id will be set. 
  29. * @since 3.0.0 
  30. * @param WC_Order_Item_Fee $item 
  31. */ 
  32. public function save_item_data( &$item ) { 
  33. $id = $item->get_id(); 
  34. $save_values = array( 
  35. '_tax_class' => $item->get_tax_class( 'edit' ),  
  36. '_tax_status' => $item->get_tax_status( 'edit' ),  
  37. '_line_total' => $item->get_total( 'edit' ),  
  38. '_line_tax' => $item->get_total_tax( 'edit' ),  
  39. '_line_tax_data' => $item->get_taxes( 'edit' ),  
  40. ); 
  41. foreach ( $save_values as $key => $value ) { 
  42. update_metadata( 'order_item', $id, $key, $value );