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

361 lines
10 KiB
JavaScript
Raw Normal View History

2018-08-02 21:27:27 +00:00
/**
* External dependencies
*/
2018-09-20 05:07:37 +00:00
import { __, _x } from '@wordpress/i18n';
2019-05-20 01:57:06 +00:00
import { applyFilters } from '@wordpress/hooks';
import { ORDER_STATUSES } from '@woocommerce/wc-admin-settings';
2018-08-02 21:27:27 +00:00
/**
* Internal dependencies
*/
import {
getCouponLabels,
getProductLabels,
getTaxRateLabels,
} from '../../../lib/async-requests';
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';
2019-05-20 01:57:06 +00:00
export const charts = applyFilters( ORDERS_REPORT_CHARTS_FILTER, [
{
key: 'orders_count',
label: __( 'Orders', 'woocommerce-admin' ),
type: 'number',
},
{
key: 'net_revenue',
Correcting and clarifying analytics terms and calculations (https://github.com/woocommerce/woocommerce-admin/pull/3104) * Relabel Net Revenue to Net Sales, revert previous refund work on Gross revenue and rename to total sales. Update the orer of all the things * Add gross sales calculation to revenue stats endpoint. * Restore coupon_total when updating order stats. * Wire up gross sales to revenue report. * Fix revenue report refunds calculation when there are no refunds. * update net sales labels and cases in order, product and category tables * Subtract refunded shipping and taxes from gross sales. * pluses to minuses to fix the gross revenue and refund totals when refunding * Add gross_sales to revenue stats orderby enum. * Change refund labels to Returns * Remove usage of defunct coupon_total column. * Store refunded amount in stats table. * Rename "gross_total" column to "total_sales". * Net total for refund orders can be used instead of a new column. * Rename gross_revenue to total_sales. * Coalesce coupons total in order stats query. SUM()ing all nulls gives null, not zero. * Use segmentation selections to backfill missing data. Fo when report columns and segmentation columns don't match. * Remove errant gross_sales from expected interval test data. * Fix gross sales tests for revenue/stats. * Move missing segment fills back to their original locations. * Fix remaining tests failing because of gross sales. * Fix db upgrade function rename of gross_total column. * Fix linter errors.
2019-11-22 15:06:14 +00:00
label: __( 'Net Sales', 'woocommerce-admin' ),
order: 'desc',
orderby: 'net_total',
type: 'currency',
},
{
key: 'avg_order_value',
label: __( 'Average Order Value', 'woocommerce-admin' ),
type: 'currency',
},
{
key: 'avg_items_per_order',
label: __( 'Average Items Per Order', 'woocommerce-admin' ),
order: 'desc',
orderby: 'num_items_sold',
type: 'average',
},
2019-05-20 01:57:06 +00:00
] );
export const filters = applyFilters( ORDERS_REPORT_FILTERS_FILTER, [
2018-10-29 01:30:24 +00:00
{
label: __( 'Show', 'woocommerce-admin' ),
staticParams: [ 'chartType', 'paged', 'per_page' ],
2018-10-29 01:30:24 +00:00
param: 'filter',
showFilters: () => true,
filters: [
{ label: __( 'All Orders', 'woocommerce-admin' ), value: 'all' },
{
label: __( 'Advanced Filters', 'woocommerce-admin' ),
value: 'advanced',
},
2018-10-29 01:30:24 +00:00
],
},
] );
2018-08-02 21:27:27 +00:00
2018-09-20 05:07:37 +00:00
/*eslint-disable max-len*/
export const advancedFilters = applyFilters(
ORDERS_REPORT_ADVANCED_FILTERS_FILTER,
{
title: _x(
'Orders Match {{select /}} Filters',
'A sentence describing filters for Orders. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ',
'woocommerce-admin'
),
filters: {
status: {
labels: {
add: __( 'Order Status', 'woocommerce-admin' ),
remove: __(
'Remove order status filter',
'woocommerce-admin'
),
rule: __(
'Select an order status filter match',
'woocommerce-admin'
),
/* translators: A sentence describing an Order Status filter. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ */
title: __(
'{{title}}Order Status{{/title}} {{rule /}} {{filter /}}',
'woocommerce-admin'
),
filter: __( 'Select an order status', 'woocommerce-admin' ),
2018-09-20 05:07:37 +00:00
},
rules: [
{
value: 'is',
/* translators: Sentence fragment, logical, "Is" refers to searching for orders matching a chosen order status. Screenshot for context: https://cloudup.com/cSsUY9VeCVJ */
label: _x( 'Is', 'order status', 'woocommerce-admin' ),
},
{
value: 'is_not',
/* translators: Sentence fragment, logical, "Is Not" refers to searching for orders that don\'t match a chosen order status. Screenshot for context: https://cloudup.com/cSsUY9VeCVJ */
label: _x(
'Is Not',
'order status',
'woocommerce-admin'
),
},
],
input: {
component: 'SelectControl',
options: Object.keys( ORDER_STATUSES ).map( ( key ) => ( {
value: key,
label: ORDER_STATUSES[ key ],
} ) ),
2018-09-20 05:07:37 +00:00
},
},
product: {
labels: {
add: __( 'Products', 'woocommerce-admin' ),
placeholder: __( 'Search products', 'woocommerce-admin' ),
remove: __( 'Remove products filter', 'woocommerce-admin' ),
rule: __(
'Select a product filter match',
'woocommerce-admin'
),
/* translators: A sentence describing a Product filter. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ */
title: __(
'{{title}}Product{{/title}} {{rule /}} {{filter /}}',
'woocommerce-admin'
),
filter: __( 'Select products', 'woocommerce-admin' ),
2018-09-20 05:07:37 +00:00
},
rules: [
{
value: 'includes',
/* translators: Sentence fragment, logical, "Includes" refers to orders including a given product(s). Screenshot for context: https://cloudup.com/cSsUY9VeCVJ */
label: _x(
'Includes',
'products',
'woocommerce-admin'
),
},
{
value: 'excludes',
/* translators: Sentence fragment, logical, "Excludes" refers to orders excluding a given product(s). Screenshot for context: https://cloudup.com/cSsUY9VeCVJ */
label: _x(
'Excludes',
'products',
'woocommerce-admin'
),
},
],
input: {
component: 'Search',
type: 'products',
getLabels: getProductLabels,
2018-09-20 05:07:37 +00:00
},
},
coupon: {
labels: {
add: __( 'Coupon Codes', 'woocommerce-admin' ),
placeholder: __( 'Search coupons', 'woocommerce-admin' ),
remove: __( 'Remove coupon filter', 'woocommerce-admin' ),
rule: __(
'Select a coupon filter match',
'woocommerce-admin'
),
/* translators: A sentence describing a Coupon filter. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ */
title: __(
'{{title}}Coupon Code{{/title}} {{rule /}} {{filter /}}',
'woocommerce-admin'
),
filter: __( 'Select coupon codes', 'woocommerce-admin' ),
2018-09-20 05:07:37 +00:00
},
rules: [
{
value: 'includes',
/* translators: Sentence fragment, logical, "Includes" refers to orders including a given coupon code(s). Screenshot for context: https://cloudup.com/cSsUY9VeCVJ */
label: _x(
'Includes',
'coupon code',
'woocommerce-admin'
),
},
{
value: 'excludes',
/* translators: Sentence fragment, logical, "Excludes" refers to orders excluding a given coupon code(s). Screenshot for context: https://cloudup.com/cSsUY9VeCVJ */
label: _x(
'Excludes',
'coupon code',
'woocommerce-admin'
),
},
2018-09-20 05:07:37 +00:00
],
input: {
component: 'Search',
type: 'coupons',
getLabels: getCouponLabels,
},
},
customer_type: {
labels: {
add: __( 'Customer Type', 'woocommerce-admin' ),
remove: __( 'Remove customer filter', 'woocommerce-admin' ),
rule: __(
'Select a customer filter match',
'woocommerce-admin'
),
/* translators: A sentence describing a Customer filter. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ */
title: __(
'{{title}}Customer is{{/title}} {{filter /}}',
'woocommerce-admin'
),
filter: __( 'Select a customer type', 'woocommerce-admin' ),
},
input: {
component: 'SelectControl',
options: [
{
value: 'new',
label: __( 'New', 'woocommerce-admin' ),
},
{
value: 'returning',
label: __( 'Returning', 'woocommerce-admin' ),
},
],
defaultOption: 'new',
},
},
refunds: {
labels: {
add: __( 'Refunds', 'woocommerce-admin' ),
remove: __( 'Remove refunds filter', 'woocommerce-admin' ),
rule: __(
'Select a refund filter match',
'woocommerce-admin'
),
title: __(
'{{title}}Refunds{{/title}} {{filter /}}',
'woocommerce-admin'
),
filter: __( 'Select a refund type', 'woocommerce-admin' ),
},
input: {
component: 'SelectControl',
options: [
{
value: 'all',
label: __( 'All', 'woocommerce-admin' ),
},
{
value: 'partial',
label: __(
'Partially refunded',
'woocommerce-admin'
),
},
{
value: 'full',
label: __( 'Fully refunded', 'woocommerce-admin' ),
},
{
value: 'none',
label: __( 'None', 'woocommerce-admin' ),
},
],
defaultOption: 'all',
},
},
tax_rate: {
labels: {
add: __( 'Tax Rates', 'woocommerce-admin' ),
placeholder: __( 'Search tax rates', 'woocommerce-admin' ),
remove: __( 'Remove tax rate filter', 'woocommerce-admin' ),
rule: __(
'Select a tax rate filter match',
'woocommerce-admin'
),
/* translators: A sentence describing a tax rate filter. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ */
title: __(
'{{title}}Tax Rate{{/title}} {{rule /}} {{filter /}}',
'woocommerce-admin'
),
filter: __( 'Select tax rates', 'woocommerce-admin' ),
},
rules: [
{
value: 'includes',
/* translators: Sentence fragment, logical, "Includes" refers to orders including a given tax rate(s). Screenshot for context: https://cloudup.com/cSsUY9VeCVJ */
label: _x(
'Includes',
'tax rate',
'woocommerce-admin'
),
},
{
value: 'excludes',
/* translators: Sentence fragment, logical, "Excludes" refers to orders excluding a given tax rate(s). Screenshot for context: https://cloudup.com/cSsUY9VeCVJ */
label: _x(
'Excludes',
'tax rate',
'woocommerce-admin'
),
},
],
input: {
component: 'Search',
type: 'taxes',
getLabels: getTaxRateLabels,
},
},
attribute: {
allowMultiple: true,
labels: {
add: __( 'Attribute', 'woocommerce-admin' ),
placeholder: __( 'Search attributes', 'woocommerce-admin' ),
remove: __(
'Remove attribute filter',
'woocommerce-admin'
),
rule: __(
'Select a product attribute filter match',
'woocommerce-admin'
),
/* translators: A sentence describing a Product filter. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ */
title: __(
'{{title}}Attribute{{/title}} {{rule /}} {{filter /}}',
'woocommerce-admin'
),
filter: __( 'Select attributes', 'woocommerce-admin' ),
},
rules: [
{
value: 'is',
/* translators: Sentence fragment, logical, "Is" refers to searching for products matching a chosen attribute. Screenshot for context: https://cloudup.com/cSsUY9VeCVJ */
label: _x(
'Is',
'product attribute',
'woocommerce-admin'
),
},
{
value: 'is_not',
/* translators: Sentence fragment, logical, "Is Not" refers to searching for products that don\'t match a chosen attribute. Screenshot for context: https://cloudup.com/cSsUY9VeCVJ */
label: _x(
'Is Not',
'product attribute',
'woocommerce-admin'
),
},
],
input: {
component: 'ProductAttribute',
},
},
},
}
);
2018-09-20 05:07:37 +00:00
/*eslint-enable max-len*/