Use core orders endpoint for "unread" order indicator.

This commit is contained in:
Jeff Stieler 2019-07-16 15:03:15 -06:00
parent 69149ab83a
commit bb4f067b61
1 changed files with 6 additions and 6 deletions

View File

@ -32,7 +32,7 @@ export function getUnreadNotes( select ) {
}
export function getUnreadOrders( select ) {
const { getReportItems, getReportItemsError, isReportItemsRequesting } = select( 'wc-api' );
const { getItemsTotalCount, getItemsError, isGetItemsRequesting } = select( 'wc-api' );
const orderStatuses =
wcSettings.wcAdminSettings.woocommerce_actionable_order_statuses || DEFAULT_ACTIONABLE_STATUSES;
@ -42,13 +42,13 @@ export function getUnreadOrders( select ) {
const ordersQuery = {
page: 1,
per_page: 0,
status_is: orderStatuses,
per_page: 1, // Core endpoint requires per_page > 0.
status: orderStatuses,
};
const totalOrders = getReportItems( 'orders', ordersQuery ).totalResults;
const isError = Boolean( getReportItemsError( 'orders', ordersQuery ) );
const isRequesting = isReportItemsRequesting( 'orders', ordersQuery );
const totalOrders = getItemsTotalCount( 'orders', ordersQuery );
const isError = Boolean( getItemsError( 'orders', ordersQuery ) );
const isRequesting = isGetItemsRequesting( 'orders', ordersQuery );
if ( isError || isRequesting ) {
return null;