Query.php
51 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class for parameter-based Orders Reports querying |
| 4 | * |
| 5 | * Example usage: |
| 6 | * $args = array( |
| 7 | * 'before' => '2018-07-19 00:00:00', |
| 8 | * 'after' => '2018-07-05 00:00:00', |
| 9 | * 'interval' => 'week', |
| 10 | * 'products' => array(15, 18), |
| 11 | * 'coupons' => array(138), |
| 12 | * 'status_is' => array('completed'), |
| 13 | * 'status_is_not' => array('failed'), |
| 14 | * 'new_customers' => false, |
| 15 | * ); |
| 16 | * $report = new \Automattic\WooCommerce\Admin\API\Reports\Orders\Query( $args ); |
| 17 | * $mydata = $report->get_data(); |
| 18 | */ |
| 19 | |
| 20 | namespace Automattic\WooCommerce\Admin\API\Reports\Orders; |
| 21 | |
| 22 | use Automattic\WooCommerce\Admin\API\Reports\GenericQuery; |
| 23 | |
| 24 | defined( 'ABSPATH' ) || exit; |
| 25 | |
| 26 | |
| 27 | /** |
| 28 | * API\Reports\Orders\Query |
| 29 | */ |
| 30 | class Query extends GenericQuery { |
| 31 | |
| 32 | /** |
| 33 | * Specific query name. |
| 34 | * Will be used to load the `report-{name}` data store, |
| 35 | * and to call `woocommerce_analytics_{snake_case(name)}_*` filters. |
| 36 | * |
| 37 | * @var string |
| 38 | */ |
| 39 | protected $name = 'orders'; |
| 40 | |
| 41 | |
| 42 | /** |
| 43 | * Get the default allowed query vars. |
| 44 | * |
| 45 | * @return array |
| 46 | */ |
| 47 | protected function get_default_query_vars() { |
| 48 | return \WC_Object_Query::get_default_query_vars(); |
| 49 | } |
| 50 | } |
| 51 |