Automattic\WooCommerce\Admin\API\Reports\Revenue

Query{}WC 1.0

API\Reports\Revenue\Query

This query uses inconsistent names:

  • report-revenue-stats data store
  • woocommerce_analytics_revenue_* filters So, for backward compatibility, we cannot use GenericQuery.

Usage

$Query = new Query();
// use class methods

Methods

  1. public get_data()
  2. public get_option( 'posts_per_page' )
  3. public array(
  4. ERROR: no method name found on line ``
  5. ERROR: no method name found on line ``
  6. ERROR: no method name found on line `'net_revenue',`
  7. ERROR: no method name found on line `'taxes',`
  8. ERROR: no method name found on line `'taxes',`
  9. ERROR: no method name found on line `'refunds',`
  10. ERROR: no method name found on line `'refunds',`
  11. ERROR: no method name found on line `'refunds',`
  12. ERROR: no method name found on line `'taxes',`
  13. ERROR: no method name found on line `'refunds',`
  14. ERROR: no method name found on line `'orderby' => 'date',`
  15. ERROR: no method name found on line `'taxes',`
  16. ERROR: no method name found on line `'taxes',`
  17. ERROR: no method name found on line `}`
  18. protected get_default_query_vars()
  19. ERROR: no method name found on line `'orderby' => 'date',`
  20. ERROR: no method name found on line `'page' => 1,`
  21. ERROR: no method name found on line `'page' => 1,`
  22. ERROR: no method name found on line `'page' => 1,`
  23. ERROR: no method name found on line ``
  24. ERROR: no method name found on line `'coupons',`
  25. ERROR: no method name found on line `'page' => 1,`
  26. ERROR: no method name found on line `'page' => 1,`
  27. ERROR: no method name found on line `'interval' => 'week',`
  28. ERROR: no method name found on line `'page' => 1,`

Query{} code WC 10.3.3

class Query extends \WC_Object_Query {

	/**
	 * Valid fields for Revenue report.
	 *
	 * @return array
	 */
	protected function get_default_query_vars() {
		return array(
			'per_page' => get_option( 'posts_per_page' ), // not sure if this should be the default.
			'page'     => 1,
			'order'    => 'DESC',
			'orderby'  => 'date',
			'before'   => '',
			'after'    => '',
			'interval' => 'week',
			'fields'   => array(
				'orders_count',
				'num_items_sold',
				'total_sales',
				'coupons',
				'coupons_count',
				'refunds',
				'taxes',
				'shipping',
				'net_revenue',
				'gross_sales',
			),
		);
	}

	/**
	 * Get revenue data based on the current query vars.
	 *
	 * @return array
	 */
	public function get_data() {
		$args = apply_filters( 'woocommerce_analytics_revenue_query_args', $this->get_query_vars() );

		$data_store = \WC_Data_Store::load( 'report-revenue-stats' );
		$results    = $data_store->get_data( $args );
		return apply_filters( 'woocommerce_analytics_revenue_select_query', $results, $args );
	}
}