2018-08-02 21:27:27 +00:00
/** @format */
/ * *
* 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
* /
2019-11-13 03:22:06 +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' ;
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-03-13 17:14:02 +00:00
label : _ _ ( 'Net Revenue' , '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' ) ,
2018-11-01 09:13:45 +00:00
staticParams : [ 'chart' ] ,
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' } ,
{ 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*/
2019-08-23 16:41:42 +00:00
export const advancedFilters = applyFilters ( ORDERS _REPORT _ADVANCED _FILTERS _FILTER , {
2018-09-20 05:07:37 +00:00
title : _x (
'Orders Match {{select /}} Filters' ,
'A sentence describing filters for Orders. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ' ,
2019-03-13 17:14:02 +00:00
'woocommerce-admin'
2018-09-20 05:07:37 +00:00
) ,
filters : {
status : {
labels : {
2019-03-13 17:14:02 +00:00
add : _ _ ( 'Order Status' , 'woocommerce-admin' ) ,
remove : _ _ ( 'Remove order status filter' , 'woocommerce-admin' ) ,
rule : _ _ ( 'Select an order status filter match' , 'woocommerce-admin' ) ,
2018-09-20 05:07:37 +00:00
/* translators: A sentence describing an Order Status filter. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ */
2019-03-13 17:14:02 +00:00
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 */
2019-03-13 17:14:02 +00:00
label : _x ( 'Is' , 'order status' , 'woocommerce-admin' ) ,
2018-09-20 05:07:37 +00:00
} ,
{
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 */
2019-03-13 17:14:02 +00:00
label : _x ( 'Is Not' , 'order status' , 'woocommerce-admin' ) ,
2018-09-20 05:07:37 +00:00
} ,
] ,
input : {
component : 'SelectControl' ,
2019-09-23 21:47:08 +00:00
options : Object . keys ( ORDER _STATUSES ) . map ( key => ( {
2018-09-20 05:07:37 +00:00
value : key ,
2019-09-23 21:47:08 +00:00
label : ORDER _STATUSES [ key ] ,
2018-09-20 05:07:37 +00:00
} ) ) ,
} ,
2018-08-02 21:27:27 +00:00
} ,
2018-09-20 05:07:37 +00:00
product : {
labels : {
2019-03-13 17:14:02 +00:00
add : _ _ ( 'Products' , 'woocommerce-admin' ) ,
placeholder : _ _ ( 'Search products' , 'woocommerce-admin' ) ,
remove : _ _ ( 'Remove products filter' , 'woocommerce-admin' ) ,
rule : _ _ ( 'Select a product filter match' , 'woocommerce-admin' ) ,
2018-09-20 05:07:37 +00:00
/* translators: A sentence describing a Product filter. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ */
2019-03-13 17:14:02 +00:00
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 */
2019-03-13 17:14:02 +00:00
label : _x ( 'Includes' , 'products' , 'woocommerce-admin' ) ,
2018-09-20 05:07:37 +00:00
} ,
{
value : 'excludes' ,
/* translators: Sentence fragment, logical, "Excludes" refers to orders excluding a given product(s). Screenshot for context: https://cloudup.com/cSsUY9VeCVJ */
2019-03-13 17:14:02 +00:00
label : _x ( 'Excludes' , 'products' , 'woocommerce-admin' ) ,
2018-09-20 05:07:37 +00:00
} ,
] ,
input : {
component : 'Search' ,
type : 'products' ,
2019-01-24 09:35:27 +00:00
getLabels : getProductLabels ,
2018-09-20 05:07:37 +00:00
} ,
2018-09-19 17:23:57 +00:00
} ,
2018-11-28 20:29:12 +00:00
coupon : {
2018-09-20 05:07:37 +00:00
labels : {
2019-03-13 17:14:02 +00:00
add : _ _ ( 'Coupon Codes' , 'woocommerce-admin' ) ,
placeholder : _ _ ( 'Search coupons' , 'woocommerce-admin' ) ,
remove : _ _ ( 'Remove coupon filter' , 'woocommerce-admin' ) ,
rule : _ _ ( 'Select a coupon filter match' , 'woocommerce-admin' ) ,
2018-09-20 05:07:37 +00:00
/* translators: A sentence describing a Coupon filter. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ */
2019-03-13 17:14:02 +00:00
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 */
2019-03-13 17:14:02 +00:00
label : _x ( 'Includes' , 'coupon code' , 'woocommerce-admin' ) ,
2018-09-20 05:07:37 +00:00
} ,
{
value : 'excludes' ,
/* translators: Sentence fragment, logical, "Excludes" refers to orders excluding a given coupon code(s). Screenshot for context: https://cloudup.com/cSsUY9VeCVJ */
2019-03-13 17:14:02 +00:00
label : _x ( 'Excludes' , 'coupon code' , 'woocommerce-admin' ) ,
2018-09-20 05:07:37 +00:00
} ,
2018-09-03 02:08:13 +00:00
] ,
2018-09-20 05:07:37 +00:00
input : {
component : 'Search' ,
type : 'coupons' ,
2019-01-24 09:35:27 +00:00
getLabels : getCouponLabels ,
2018-09-20 05:07:37 +00:00
} ,
} ,
2019-05-07 05:17:43 +00:00
customer _type : {
2018-09-20 05:07:37 +00:00
labels : {
2019-03-13 17:14:02 +00:00
add : _ _ ( 'Customer Type' , 'woocommerce-admin' ) ,
remove : _ _ ( 'Remove customer filter' , 'woocommerce-admin' ) ,
rule : _ _ ( 'Select a customer filter match' , 'woocommerce-admin' ) ,
2018-09-20 05:07:37 +00:00
/* translators: A sentence describing a Customer filter. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ */
2019-03-13 17:14:02 +00:00
title : _ _ ( '{{title}}Customer is{{/title}} {{filter /}}' , 'woocommerce-admin' ) ,
filter : _ _ ( 'Select a customer type' , 'woocommerce-admin' ) ,
2018-09-20 05:07:37 +00:00
} ,
input : {
component : 'SelectControl' ,
options : [
2019-03-13 17:14:02 +00:00
{ value : 'new' , label : _ _ ( 'New' , 'woocommerce-admin' ) } ,
{ value : 'returning' , label : _ _ ( 'Returning' , 'woocommerce-admin' ) } ,
2018-09-20 05:07:37 +00:00
] ,
defaultOption : 'new' ,
} ,
2018-09-03 02:08:13 +00:00
} ,
2019-05-10 06:56:57 +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
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 ,
} ,
} ,
2018-08-02 21:27:27 +00:00
} ,
2019-08-23 16:41:42 +00:00
} ) ;
2018-09-20 05:07:37 +00:00
/*eslint-enable max-len*/