Automattic\WooCommerce\Admin\API
ActivityPanelCounts::get_counts
Return the orders/reviews/low-stock counts used by the Activity Panel in one response, instead of one request per count.
Метод класса: ActivityPanelCounts{}
Хуков нет.
Возвращает
\WP_REST_Response.
Использование
$ActivityPanelCounts = new ActivityPanelCounts(); $ActivityPanelCounts->get_counts( $request );
- $request(обязательный)
- .
Код ActivityPanelCounts::get_counts() ActivityPanelCounts::get counts WC 11.2.2
public function get_counts( $request ) {
$order_statuses = (array) $request->get_param( 'order_statuses' );
// When a merchant has cleared every actionable order status there is nothing
// "to fulfill". Short-circuit to 0 rather than querying: an empty status list
// would otherwise count every order, and the previous client-side
// getUnreadOrders() returned 0 in this case.
$orders_to_fulfill_count = empty( $order_statuses )
? 0
: $this->get_count_via(
'/wc-analytics/orders',
array(
'page' => 1,
'per_page' => 1,
'status' => $order_statuses,
'_fields' => array( 'id' ),
)
);
return rest_ensure_response(
array(
'orders_to_fulfill_count' => $orders_to_fulfill_count,
'reviews_to_moderate_count' => $this->get_count_via(
'/wc-analytics/products/reviews',
array(
'page' => 1,
'per_page' => 1,
'status' => $request->get_param( 'review_status' ),
'_fields' => array( 'id' ),
)
),
'products_low_in_stock_count' => $this->get_count_via(
'/wc-analytics/products/count-low-in-stock',
array( 'status' => $request->get_param( 'product_status' ) )
),
)
);
}