woocommerce/plugins/woocommerce-admin/client/analytics/report/revenue/config.js

97 lines
2.2 KiB
JavaScript

/**
* External dependencies
*/
import { __, _x } from '@wordpress/i18n';
import { applyFilters } from '@wordpress/hooks';
const REVENUE_REPORT_CHARTS_FILTER = 'woocommerce_admin_revenue_report_charts';
const REVENUE_REPORT_FILTERS_FILTER =
'woocommerce_admin_revenue_report_filters';
const REVENUE_REPORT_ADVANCED_FILTERS_FILTER =
'woocommerce_admin_revenue_report_advanced_filters';
export const charts = applyFilters( REVENUE_REPORT_CHARTS_FILTER, [
{
key: 'gross_sales',
label: __( 'Gross Sales', 'woocommerce-admin' ),
order: 'desc',
orderby: 'gross_sales',
type: 'currency',
},
{
key: 'refunds',
label: __( 'Returns', 'woocommerce-admin' ),
order: 'desc',
orderby: 'refunds',
type: 'currency',
},
{
key: 'coupons',
label: __( 'Coupons', 'woocommerce-admin' ),
order: 'desc',
orderby: 'coupons',
type: 'currency',
},
{
key: 'net_revenue',
label: __( 'Net Sales', 'woocommerce-admin' ),
orderby: 'net_revenue',
type: 'currency',
},
{
key: 'taxes',
label: __( 'Taxes', 'woocommerce-admin' ),
order: 'desc',
orderby: 'taxes',
type: 'currency',
},
{
key: 'shipping',
label: __( 'Shipping', 'woocommerce-admin' ),
orderby: 'shipping',
type: 'currency',
},
{
key: 'total_sales',
label: __( 'Total Sales', 'woocommerce-admin' ),
order: 'desc',
orderby: 'total_sales',
type: 'currency',
},
] );
export const advancedFilters = applyFilters(
REVENUE_REPORT_ADVANCED_FILTERS_FILTER,
{
filters: {},
title: _x(
'Revenue Matches {{select /}} Filters',
'A sentence describing filters for Revenue. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ',
'woocommerce-admin'
),
}
);
const filterValues = [];
if ( Object.keys( advancedFilters.filters ).length ) {
filterValues.push( {
label: __( 'All Revenue', 'woocommerce-admin' ),
value: 'all',
} );
filterValues.push( {
label: __( 'Advanced Filters', 'woocommerce-admin' ),
value: 'advanced',
} );
}
export const filters = applyFilters( REVENUE_REPORT_FILTERS_FILTER, [
{
label: __( 'Show', 'woocommerce-admin' ),
staticParams: [ 'chartType', 'paged', 'per_page' ],
param: 'filter',
showFilters: () => filterValues.length > 0,
filters: filterValues,
},
] );