Query.php
52 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class for parameter-based Customers Report querying |
| 4 | * |
| 5 | * Example usage: |
| 6 | * $args = array( |
| 7 | * 'registered_before' => '2018-07-19 00:00:00', |
| 8 | * 'registered_after' => '2018-07-05 00:00:00', |
| 9 | * 'page' => 2, |
| 10 | * 'avg_order_value_min' => 100, |
| 11 | * 'country' => 'GB', |
| 12 | * ); |
| 13 | * $report = new \Automattic\WooCommerce\Admin\API\Reports\Customers\Query( $args ); |
| 14 | * $mydata = $report->get_data(); |
| 15 | */ |
| 16 | |
| 17 | namespace Automattic\WooCommerce\Admin\API\Reports\Customers; |
| 18 | |
| 19 | use Automattic\WooCommerce\Admin\API\Reports\GenericQuery; |
| 20 | |
| 21 | defined( 'ABSPATH' ) || exit; |
| 22 | |
| 23 | /** |
| 24 | * API\Reports\Customers\Query |
| 25 | */ |
| 26 | class Query extends GenericQuery { |
| 27 | |
| 28 | /** |
| 29 | * Specific query name. |
| 30 | * Will be used to load the `report-{name}` data store, |
| 31 | * and to call `woocommerce_analytics_{snake_case(name)}_*` filters. |
| 32 | * |
| 33 | * @var string |
| 34 | */ |
| 35 | protected $name = 'customers'; |
| 36 | |
| 37 | /** |
| 38 | * Valid fields for Customers report. |
| 39 | * |
| 40 | * @return array |
| 41 | */ |
| 42 | protected function get_default_query_vars() { |
| 43 | return array( |
| 44 | 'per_page' => get_option( 'posts_per_page' ), // not sure if this should be the default. |
| 45 | 'page' => 1, |
| 46 | 'order' => 'DESC', |
| 47 | 'orderby' => 'date_registered', |
| 48 | 'fields' => '*', |
| 49 | ); |
| 50 | } |
| 51 | } |
| 52 |