/** * External dependencies */ import { __, _x } from '@wordpress/i18n'; import { applyFilters } from '@wordpress/hooks'; /** * Internal dependencies */ import { getCouponLabels, getProductLabels, getTaxRateLabels, getVariationLabels, } from '../../../lib/async-requests'; import { ORDER_STATUSES } from '~/utils/admin-settings'; const ORDERS_REPORT_CHARTS_FILTER = 'woocommerce_admin_orders_report_charts'; const ORDERS_REPORT_FILTERS_FILTER = 'woocommerce_admin_orders_report_filters'; const ORDERS_REPORT_ADVANCED_FILTERS_FILTER = 'woocommerce_admin_orders_report_advanced_filters'; /** * @typedef {import('../index.js').chart} chart */ /** * Orders Report charts filter. * * @filter woocommerce_admin_orders_report_charts * @param {Array.} charts Report charts. */ export const charts = applyFilters( ORDERS_REPORT_CHARTS_FILTER, [ { key: 'orders_count', label: __( 'Orders', 'woocommerce' ), type: 'number', }, { key: 'net_revenue', label: __( 'Net sales', 'woocommerce' ), order: 'desc', orderby: 'net_total', type: 'currency', }, { key: 'avg_order_value', label: __( 'Average order value', 'woocommerce' ), type: 'currency', }, { key: 'avg_items_per_order', label: __( 'Average items per order', 'woocommerce' ), order: 'desc', orderby: 'num_items_sold', type: 'average', }, ] ); /** * @typedef {import('../index.js').filter} filter */ /** * Orders Report Filters. * * @filter woocommerce_admin_orders_report_filters * @param {Array.} filters Report filters. */ export const filters = applyFilters( ORDERS_REPORT_FILTERS_FILTER, [ { label: __( 'Show', 'woocommerce' ), staticParams: [ 'chartType', 'paged', 'per_page' ], param: 'filter', showFilters: () => true, filters: [ { label: __( 'All orders', 'woocommerce' ), value: 'all' }, { label: __( 'Advanced filters', 'woocommerce' ), value: 'advanced', }, ], }, ] ); /*eslint-disable max-len*/ /** * Orders Report Advanced Filters. * * @filter woocommerce_admin_orders_report_advanced_filters * @param {Object} advancedFilters Report Advanced Filters. * @param {string} advancedFilters.title Interpolated component string for Advanced Filters title. * @param {Object} advancedFilters.filters An object specifying a report's Advanced Filters. */ export const advancedFilters = applyFilters( ORDERS_REPORT_ADVANCED_FILTERS_FILTER, { title: _x( 'Orders match