class-wc-order-query.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * Parameter-based Order querying
  4. * Args and usage: https://github.com/woocommerce/woocommerce/wiki/wc_get_orders-and-WC_Order_Query
  5. *
  6. * @package WooCommerce/Classes
  7. * @version 3.1.0
  8. * @since 3.1.0
  9. */
  10. defined( 'ABSPATH' ) || exit;
  11. /**
  12. * Order query class.
  13. */
  14. class WC_Order_Query extends WC_Object_Query {
  15. /**
  16. * Valid query vars for orders.
  17. *
  18. * @return array
  19. */
  20. protected function get_default_query_vars() {
  21. return array_merge(
  22. parent::get_default_query_vars(),
  23. array(
  24. 'status' => array_keys( wc_get_order_statuses() ),
  25. 'type' => wc_get_order_types( 'view-orders' ),
  26. 'currency' => '',
  27. 'version' => '',
  28. 'prices_include_tax' => '',
  29. 'date_created' => '',
  30. 'date_modified' => '',
  31. 'date_completed' => '',
  32. 'date_paid' => '',
  33. 'discount_total' => '',
  34. 'discount_tax' => '',
  35. 'shipping_total' => '',
  36. 'shipping_tax' => '',
  37. 'cart_tax' => '',
  38. 'total' => '',
  39. 'total_tax' => '',
  40. 'customer' => '',
  41. 'customer_id' => '',
  42. 'order_key' => '',
  43. 'billing_first_name' => '',
  44. 'billing_last_name' => '',
  45. 'billing_company' => '',
  46. 'billing_address_1' => '',
  47. 'billing_address_2' => '',
  48. 'billing_city' => '',
  49. 'billing_state' => '',
  50. 'billing_postcode' => '',
  51. 'billing_country' => '',
  52. 'billing_email' => '',
  53. 'billing_phone' => '',
  54. 'shipping_first_name' => '',
  55. 'shipping_last_name' => '',
  56. 'shipping_company' => '',
  57. 'shipping_address_1' => '',
  58. 'shipping_address_2' => '',
  59. 'shipping_city' => '',
  60. 'shipping_state' => '',
  61. 'shipping_postcode' => '',
  62. 'shipping_country' => '',
  63. 'payment_method' => '',
  64. 'payment_method_title' => '',
  65. 'transaction_id' => '',
  66. 'customer_ip_address' => '',
  67. 'customer_user_agent' => '',
  68. 'created_via' => '',
  69. 'customer_note' => '',
  70. )
  71. );
  72. }
  73. /**
  74. * Get orders matching the current query vars.
  75. *
  76. * @return array|object of WC_Order objects
  77. */
  78. public function get_orders() {
  79. $args = apply_filters( 'woocommerce_order_query_args', $this->get_query_vars() );
  80. $results = WC_Data_Store::load( 'order' )->query( $args );
  81. return apply_filters( 'woocommerce_order_query', $results, $args );
  82. }
  83. }