2019-05-20 01:57:06 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2019-06-15 12:12:19 +00:00
|
|
|
import { __ } from '@wordpress/i18n';
|
2019-05-20 01:57:06 +00:00
|
|
|
import { applyFilters } from '@wordpress/hooks';
|
|
|
|
|
2018-12-22 00:24:26 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2020-08-13 02:05:22 +00:00
|
|
|
import { charts as ordersCharts } from '../../analytics/report/orders/config';
|
|
|
|
import { charts as productsCharts } from '../../analytics/report/products/config';
|
|
|
|
import { charts as revenueCharts } from '../../analytics/report/revenue/config';
|
|
|
|
import { charts as couponsCharts } from '../../analytics/report/coupons/config';
|
|
|
|
import { charts as taxesCharts } from '../../analytics/report/taxes/config';
|
|
|
|
import { charts as downloadsCharts } from '../../analytics/report/downloads/config';
|
2019-05-20 01:57:06 +00:00
|
|
|
|
|
|
|
const DASHBOARD_CHARTS_FILTER = 'woocommerce_admin_dashboard_charts_filter';
|
2018-12-22 00:24:26 +00:00
|
|
|
|
2019-06-15 12:12:19 +00:00
|
|
|
const charts = {
|
|
|
|
revenue: revenueCharts,
|
|
|
|
orders: ordersCharts,
|
|
|
|
products: productsCharts,
|
|
|
|
coupons: couponsCharts,
|
|
|
|
taxes: taxesCharts,
|
|
|
|
downloads: downloadsCharts,
|
|
|
|
};
|
2018-12-22 00:24:26 +00:00
|
|
|
|
2019-06-15 12:12:19 +00:00
|
|
|
const defaultCharts = [
|
|
|
|
{
|
2021-08-13 18:54:24 +00:00
|
|
|
label: __( 'Total sales', 'woocommerce-admin' ),
|
2019-06-15 12:12:19 +00:00
|
|
|
report: 'revenue',
|
2019-11-22 15:06:14 +00:00
|
|
|
key: 'total_sales',
|
2019-06-15 12:12:19 +00:00
|
|
|
},
|
|
|
|
{
|
2021-08-13 18:54:24 +00:00
|
|
|
label: __( 'Net sales', 'woocommerce-admin' ),
|
2019-06-15 12:12:19 +00:00
|
|
|
report: 'revenue',
|
|
|
|
key: 'net_revenue',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: __( 'Orders', 'woocommerce-admin' ),
|
|
|
|
report: 'orders',
|
|
|
|
key: 'orders_count',
|
|
|
|
},
|
|
|
|
{
|
2021-08-13 18:54:24 +00:00
|
|
|
label: __( 'Average order value', 'woocommerce-admin' ),
|
2019-06-15 12:12:19 +00:00
|
|
|
report: 'orders',
|
|
|
|
key: 'avg_order_value',
|
|
|
|
},
|
|
|
|
{
|
2021-08-13 18:54:24 +00:00
|
|
|
label: __( 'Items sold', 'woocommerce-admin' ),
|
2019-06-15 12:12:19 +00:00
|
|
|
report: 'products',
|
|
|
|
key: 'items_sold',
|
|
|
|
},
|
|
|
|
{
|
2020-01-03 23:12:53 +00:00
|
|
|
label: __( 'Returns', 'woocommerce-admin' ),
|
2019-06-15 12:12:19 +00:00
|
|
|
report: 'revenue',
|
|
|
|
key: 'refunds',
|
|
|
|
},
|
|
|
|
{
|
2021-08-13 18:54:24 +00:00
|
|
|
label: __( 'Discounted orders', 'woocommerce-admin' ),
|
2019-06-15 12:12:19 +00:00
|
|
|
report: 'coupons',
|
|
|
|
key: 'orders_count',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: __( 'Gross discounted', 'woocommerce-admin' ),
|
|
|
|
report: 'coupons',
|
|
|
|
key: 'amount',
|
|
|
|
},
|
|
|
|
{
|
2021-08-13 18:54:24 +00:00
|
|
|
label: __( 'Total tax', 'woocommerce-admin' ),
|
2019-06-15 12:12:19 +00:00
|
|
|
report: 'taxes',
|
|
|
|
key: 'total_tax',
|
|
|
|
},
|
|
|
|
{
|
2021-08-13 18:54:24 +00:00
|
|
|
label: __( 'Order tax', 'woocommerce-admin' ),
|
2019-06-15 12:12:19 +00:00
|
|
|
report: 'taxes',
|
|
|
|
key: 'order_tax',
|
|
|
|
},
|
|
|
|
{
|
2021-08-13 18:54:24 +00:00
|
|
|
label: __( 'Shipping tax', 'woocommerce-admin' ),
|
2019-06-15 12:12:19 +00:00
|
|
|
report: 'taxes',
|
|
|
|
key: 'shipping_tax',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: __( 'Shipping', 'woocommerce-admin' ),
|
|
|
|
report: 'revenue',
|
|
|
|
key: 'shipping',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: __( 'Downloads', 'woocommerce-admin' ),
|
|
|
|
report: 'downloads',
|
|
|
|
key: 'download_count',
|
|
|
|
},
|
|
|
|
];
|
2018-12-22 00:24:26 +00:00
|
|
|
|
2022-02-11 14:38:38 +00:00
|
|
|
/**
|
|
|
|
* Dashboard Charts section charts.
|
|
|
|
*
|
|
|
|
* @filter woocommerce_admin_dashboard_charts_filter
|
|
|
|
* @param {Array.<Object>} charts Array of visible charts.
|
|
|
|
*/
|
2019-06-15 12:12:19 +00:00
|
|
|
export const uniqCharts = applyFilters(
|
|
|
|
DASHBOARD_CHARTS_FILTER,
|
2020-02-14 02:23:21 +00:00
|
|
|
defaultCharts.map( ( chartDef ) => ( {
|
|
|
|
...charts[ chartDef.report ].find(
|
|
|
|
( chart ) => chart.key === chartDef.key
|
|
|
|
),
|
2019-06-15 12:12:19 +00:00
|
|
|
label: chartDef.label,
|
|
|
|
endpoint: chartDef.report,
|
|
|
|
} ) )
|
|
|
|
);
|