class-wc-order-item-data-store-interface.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /**
  3. * Order Item Data Store Interface
  4. *
  5. * @version 3.0.0
  6. * @package WooCommerce/Interface
  7. */
  8. if ( ! defined( 'ABSPATH' ) ) {
  9. exit;
  10. }
  11. /**
  12. * WC Order Item Data Store Interface
  13. *
  14. * Functions that must be defined by the order item data store (for functions).
  15. *
  16. * @version 3.0.0
  17. */
  18. interface WC_Order_Item_Data_Store_Interface {
  19. /**
  20. * Add an order item to an order.
  21. *
  22. * @param int $order_id Order ID.
  23. * @param array $item order_item_name and order_item_type.
  24. * @return int Order Item ID
  25. */
  26. public function add_order_item( $order_id, $item );
  27. /**
  28. * Update an order item.
  29. *
  30. * @param int $item_id Item ID.
  31. * @param array $item order_item_name or order_item_type.
  32. * @return boolean
  33. */
  34. public function update_order_item( $item_id, $item );
  35. /**
  36. * Delete an order item.
  37. *
  38. * @param int $item_id Item ID.
  39. */
  40. public function delete_order_item( $item_id );
  41. /**
  42. * Update term meta.
  43. *
  44. * @param int $item_id Item ID.
  45. * @param string $meta_key Meta key.
  46. * @param mixed $meta_value Meta value.
  47. * @param string $prev_value Previous value (default: '').
  48. * @return bool
  49. */
  50. public function update_metadata( $item_id, $meta_key, $meta_value, $prev_value = '' );
  51. /**
  52. * Add term meta.
  53. *
  54. * @param int $item_id Item ID.
  55. * @param string $meta_key Meta key.
  56. * @param mixed $meta_value Meta value.
  57. * @param bool $unique Unique? (default: false).
  58. * @return int New row ID or 0
  59. */
  60. public function add_metadata( $item_id, $meta_key, $meta_value, $unique = false );
  61. /**
  62. * Delete term meta.
  63. *
  64. * @param int $item_id Item ID.
  65. * @param string $meta_key Meta key.
  66. * @param string $meta_value Meta value (default: '').
  67. * @param bool $delete_all Delete all matching entries? (default: false).
  68. * @return bool
  69. */
  70. public function delete_metadata( $item_id, $meta_key, $meta_value = '', $delete_all = false );
  71. /**
  72. * Get term meta.
  73. *
  74. * @param int $item_id Item ID.
  75. * @param string $key Meta key.
  76. * @param bool $single Store as single value and not serialised (default: true).
  77. * @return mixed
  78. */
  79. public function get_metadata( $item_id, $key, $single = true );
  80. /**
  81. * Get order ID by order item ID.
  82. *
  83. * @param int $item_id Item ID.
  84. * @return int
  85. */
  86. public function get_order_id_by_order_item_id( $item_id );
  87. /**
  88. * Get the order item type based on Item ID.
  89. *
  90. * @param int $item_id Item ID.
  91. * @return string
  92. */
  93. public function get_order_item_type( $item_id );
  94. }