Automattic\WooCommerce\Admin\API\Reports\PerformanceIndicators
Controller::sort
Sorts the list of stats. Sorted by custom arrangement.
Method of the class: Controller{}
Hooks from the method
Returns
order.
Usage
$Controller = new Controller(); $Controller->sort( $a, $b );
- $a(object) (required)
- First item.
- $b(object) (required)
- Second item.
Notes
Controller::sort() Controller::sort code WC 10.5.0
public function sort( $a, $b ) {
/**
* Custom ordering for store performance indicators.
*
* @see https://github.com/woocommerce/woocommerce-admin/issues/1282
* @param array $indicators A list of ordered indicators.
*/
$stat_order = apply_filters(
'woocommerce_rest_report_sort_performance_indicators',
array(
'revenue/total_sales',
'revenue/net_revenue',
'orders/orders_count',
'orders/avg_order_value',
'products/items_sold',
'revenue/refunds',
'coupons/orders_count',
'coupons/amount',
'taxes/total_tax',
'taxes/order_tax',
'taxes/shipping_tax',
'revenue/shipping',
'downloads/download_count',
)
);
$a = array_search( $a->stat, $stat_order, true );
$b = array_search( $b->stat, $stat_order, true );
if ( false === $a && false === $b ) {
return 0;
} elseif ( false === $a ) {
return 1;
} elseif ( false === $b ) {
return -1;
} else {
return $a - $b;
}
}