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 = [
|
|
|
|
{
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Total sales', 'woocommerce' ),
|
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
|
|
|
},
|
|
|
|
{
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Net sales', 'woocommerce' ),
|
2019-06-15 12:12:19 +00:00
|
|
|
report: 'revenue',
|
|
|
|
key: 'net_revenue',
|
|
|
|
},
|
|
|
|
{
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Orders', 'woocommerce' ),
|
2019-06-15 12:12:19 +00:00
|
|
|
report: 'orders',
|
|
|
|
key: 'orders_count',
|
|
|
|
},
|
|
|
|
{
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Average order value', 'woocommerce' ),
|
2019-06-15 12:12:19 +00:00
|
|
|
report: 'orders',
|
|
|
|
key: 'avg_order_value',
|
|
|
|
},
|
|
|
|
{
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Items sold', 'woocommerce' ),
|
2019-06-15 12:12:19 +00:00
|
|
|
report: 'products',
|
|
|
|
key: 'items_sold',
|
|
|
|
},
|
|
|
|
{
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Returns', 'woocommerce' ),
|
2019-06-15 12:12:19 +00:00
|
|
|
report: 'revenue',
|
|
|
|
key: 'refunds',
|
|
|
|
},
|
|
|
|
{
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Discounted orders', 'woocommerce' ),
|
2019-06-15 12:12:19 +00:00
|
|
|
report: 'coupons',
|
|
|
|
key: 'orders_count',
|
|
|
|
},
|
|
|
|
{
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Gross discounted', 'woocommerce' ),
|
2019-06-15 12:12:19 +00:00
|
|
|
report: 'coupons',
|
|
|
|
key: 'amount',
|
|
|
|
},
|
|
|
|
{
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Total tax', 'woocommerce' ),
|
2019-06-15 12:12:19 +00:00
|
|
|
report: 'taxes',
|
|
|
|
key: 'total_tax',
|
|
|
|
},
|
|
|
|
{
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Order tax', 'woocommerce' ),
|
2019-06-15 12:12:19 +00:00
|
|
|
report: 'taxes',
|
|
|
|
key: 'order_tax',
|
|
|
|
},
|
|
|
|
{
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Shipping tax', 'woocommerce' ),
|
2019-06-15 12:12:19 +00:00
|
|
|
report: 'taxes',
|
|
|
|
key: 'shipping_tax',
|
|
|
|
},
|
|
|
|
{
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Shipping', 'woocommerce' ),
|
2019-06-15 12:12:19 +00:00
|
|
|
report: 'revenue',
|
|
|
|
key: 'shipping',
|
|
|
|
},
|
|
|
|
{
|
2022-03-30 09:00:04 +00:00
|
|
|
label: __( 'Downloads', 'woocommerce' ),
|
2019-06-15 12:12:19 +00:00
|
|
|
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,
|
|
|
|
} ) )
|
|
|
|
);
|