Automattic\WooCommerce\Admin\API\Reports\PerformanceIndicators
Controller::sort()
Sorts the list of stats. Sorted by custom arrangement.
Метод класса: Controller{}
Хуки из метода
Возвращает
order
.
Использование
$Controller = new Controller(); $Controller->sort( $a, $b );
- $a(объект) (обязательный)
- First item.
- $b(объект) (обязательный)
- Second item.
Заметки
Код Controller::sort() Controller::sort WC 9.7.1
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; } }