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' ;
2019-09-23 21:47:08 +00:00
import { ORDER _STATUSES } from '@woocommerce/wc-admin-settings' ;
2018-08-02 21:27:27 +00:00
2018-09-11 07:58:11 +00:00
/ * *
* Internal dependencies
* /
2020-02-14 02:23:21 +00:00
import {
getCouponLabels ,
getProductLabels ,
getTaxRateLabels ,
} from 'lib/async-requests' ;
2018-09-11 07:58:11 +00:00
2019-08-28 14:55:55 +00:00
const ORDERS _REPORT _CHARTS _FILTER = 'woocommerce_admin_orders_report_charts' ;
2019-08-23 16:41:42 +00:00
const ORDERS _REPORT _FILTERS _FILTER = 'woocommerce_admin_orders_report_filters' ;
2020-02-14 02:23:21 +00:00
const ORDERS _REPORT _ADVANCED _FILTERS _FILTER =
'woocommerce_admin_orders_report_advanced_filters' ;
2019-05-20 01:57:06 +00:00
2019-08-28 14:55:55 +00:00
export const charts = applyFilters ( ORDERS _REPORT _CHARTS _FILTER , [
2018-11-07 16:38:34 +00:00
{
key : 'orders_count' ,
2019-08-26 22:37:16 +00:00
label : _ _ ( 'Orders' , 'woocommerce-admin' ) ,
2018-11-07 16:38:34 +00:00
type : 'number' ,
} ,
{
key : 'net_revenue' ,
2019-11-22 15:06:14 +00:00
label : _ _ ( 'Net Sales' , 'woocommerce-admin' ) ,
2019-02-15 10:54:41 +00:00
order : 'desc' ,
orderby : 'net_total' ,
2018-11-07 16:38:34 +00:00
type : 'currency' ,
} ,
{
key : 'avg_order_value' ,
2019-03-13 17:14:02 +00:00
label : _ _ ( 'Average Order Value' , 'woocommerce-admin' ) ,
2018-11-07 16:38:34 +00:00
type : 'currency' ,
} ,
{
key : 'avg_items_per_order' ,
2019-03-13 17:14:02 +00:00
label : _ _ ( 'Average Items Per Order' , 'woocommerce-admin' ) ,
2019-02-15 10:54:41 +00:00
order : 'desc' ,
orderby : 'num_items_sold' ,
2018-11-07 16:38:34 +00:00
type : 'average' ,
} ,
2019-05-20 01:57:06 +00:00
] ) ;
2018-11-07 16:38:34 +00:00
2019-08-23 16:41:42 +00:00
export const filters = applyFilters ( ORDERS _REPORT _FILTERS _FILTER , [
2018-10-29 01:30:24 +00:00
{
2019-03-13 17:14:02 +00:00
label : _ _ ( 'Show' , 'woocommerce-admin' ) ,
2020-07-08 00:38:50 +00:00
staticParams : [ 'chartType' , 'paged' , 'per_page' ] ,
2018-10-29 01:30:24 +00:00
param : 'filter' ,
showFilters : ( ) => true ,
filters : [
2019-03-13 17:14:02 +00:00
{ label : _ _ ( 'All Orders' , 'woocommerce-admin' ) , value : 'all' } ,
2020-02-14 02:23:21 +00:00
{
label : _ _ ( 'Advanced Filters' , 'woocommerce-admin' ) ,
value : 'advanced' ,
} ,
2018-10-29 01:30:24 +00:00
] ,
} ,
2019-08-23 16:41:42 +00:00
] ) ;
2018-08-02 21:27:27 +00:00
2018-09-20 05:07:37 +00:00
/*eslint-disable max-len*/
2020-02-14 02:23:21 +00:00
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
} ,
2020-02-14 02:23:21 +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
} ,
} ,
2020-02-14 02:23:21 +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
} ,
2020-02-14 02:23:21 +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
} ,
} ,
2020-02-14 02:23:21 +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
} ,
2020-02-14 02:23:21 +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
] ,
2020-02-14 02:23:21 +00:00
input : {
component : 'Search' ,
type : 'coupons' ,
getLabels : getCouponLabels ,
} ,
2019-05-10 06:56:57 +00:00
} ,
2020-02-14 02:23:21 +00:00
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' ,
} ,
2019-05-10 06:56:57 +00:00
} ,
2020-02-14 02:23:21 +00:00
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' ,
} ,
2019-11-13 03:22:06 +00:00
} ,
2020-02-14 02:23:21 +00:00
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' ) ,
2019-11-13 03:22:06 +00:00
} ,
2020-02-14 02:23:21 +00:00
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 ,
2019-11-13 03:22:06 +00:00
} ,
} ,
} ,
2020-02-14 02:23:21 +00:00
}
) ;
2018-09-20 05:07:37 +00:00
/*eslint-enable max-len*/