class-wc-coupon-data-store-interface.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * Coupon Data Store Interface
  4. *
  5. * @version 3.0.0
  6. * @package WooCommerce/Interfaces
  7. */
  8. if ( ! defined( 'ABSPATH' ) ) {
  9. exit;
  10. }
  11. /**
  12. * WC Coupon Data Store Interface
  13. *
  14. * Functions that must be defined by coupon store classes.
  15. *
  16. * @version 3.0.0
  17. */
  18. interface WC_Coupon_Data_Store_Interface {
  19. /**
  20. * Increase usage count for current coupon.
  21. *
  22. * @param WC_Coupon $coupon Coupon object.
  23. * @param string $used_by Either user ID or billing email.
  24. */
  25. public function increase_usage_count( &$coupon, $used_by = '' );
  26. /**
  27. * Decrease usage count for current coupon.
  28. *
  29. * @param WC_Coupon $coupon Coupon object.
  30. * @param string $used_by Either user ID or billing email.
  31. */
  32. public function decrease_usage_count( &$coupon, $used_by = '' );
  33. /**
  34. * Get the number of uses for a coupon by user ID.
  35. *
  36. * @param WC_Coupon $coupon Coupon object.
  37. * @param int $user_id User ID.
  38. * @return int
  39. */
  40. public function get_usage_by_user_id( &$coupon, $user_id );
  41. /**
  42. * Return a coupon code for a specific ID.
  43. *
  44. * @param int $id Coupon ID.
  45. * @return string Coupon Code.
  46. */
  47. public function get_code_by_id( $id );
  48. /**
  49. * Return an array of IDs for for a specific coupon code.
  50. * Can return multiple to check for existence.
  51. *
  52. * @param string $code Coupon code.
  53. * @return array Array of IDs.
  54. */
  55. public function get_ids_by_code( $code );
  56. }