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' ;
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 ,
2020-09-25 13:57:48 +00:00
getVariationLabels ,
2020-08-13 02:05:22 +00:00
} from '../../../lib/async-requests' ;
2022-01-06 12:53:30 +00:00
import { ORDER _STATUSES } from '~/utils/admin-settings' ;
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
2022-02-11 14:38:38 +00:00
/ * *
* @ typedef { import ( '../index.js' ) . chart } chart
* /
/ * *
* Orders Report charts filter .
*
* @ filter woocommerce _admin _orders _report _charts
* @ param { Array . < chart > } charts Report charts .
* /
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' ,
2021-08-13 18:54:24 +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' ,
2021-08-13 18:54:24 +00:00
label : _ _ ( 'Average order value' , 'woocommerce-admin' ) ,
2018-11-07 16:38:34 +00:00
type : 'currency' ,
} ,
{
key : 'avg_items_per_order' ,
2021-08-13 18:54:24 +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
2022-02-11 14:38:38 +00:00
/ * *
* @ typedef { import ( '../index.js' ) . filter } filter
* /
/ * *
* Orders Report Filters .
*
* @ filter woocommerce _admin _orders _report _filters
* @ param { Array . < filter > } filters Report filters .
* /
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 : [
2021-08-13 18:54:24 +00:00
{ label : _ _ ( 'All orders' , 'woocommerce-admin' ) , value : 'all' } ,
2020-02-14 02:23:21 +00:00
{
2021-08-13 18:54:24 +00:00
label : _ _ ( 'Advanced filters' , 'woocommerce-admin' ) ,
2020-02-14 02:23:21 +00:00
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*/
2022-02-11 14:38:38 +00:00
/ * *
* Orders Report Advanced Filters .
*
* @ filter woocommerce _admin _orders _report _advanced _filters
* @ param { Object } advancedFilters Report Advanced Filters .
* @ param { string } advancedFilters . title Interpolated component string for Advanced Filters title .
* @ param { Object } advancedFilters . filters An object specifying a report ' s Advanced Filters .
* /
2020-02-14 02:23:21 +00:00
export const advancedFilters = applyFilters (
ORDERS _REPORT _ADVANCED _FILTERS _FILTER ,
{
title : _x (
2021-08-13 18:54:24 +00:00
'Orders match {{select /}} filters' ,
2020-02-14 02:23:21 +00:00
'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-09-25 13:57:48 +00:00
variation : {
labels : {
add : _ _ ( 'Variations' , 'woocommerce-admin' ) ,
placeholder : _ _ ( 'Search variations' , 'woocommerce-admin' ) ,
remove : _ _ (
'Remove variations filter' ,
'woocommerce-admin'
) ,
rule : _ _ (
'Select a variation filter match' ,
'woocommerce-admin'
) ,
/* translators: A sentence describing a Variation filter. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ */
title : _ _ (
'{{title}}Variation{{/title}} {{rule /}} {{filter /}}' ,
'woocommerce-admin'
) ,
filter : _ _ ( 'Select variation' , 'woocommerce-admin' ) ,
} ,
rules : [
{
value : 'includes' ,
/* translators: Sentence fragment, logical, "Includes" refers to orders including a given variation(s). Screenshot for context: https://cloudup.com/cSsUY9VeCVJ */
label : _x (
'Includes' ,
'variations' ,
'woocommerce-admin'
) ,
} ,
{
value : 'excludes' ,
/* translators: Sentence fragment, logical, "Excludes" refers to orders excluding a given variation(s). Screenshot for context: https://cloudup.com/cSsUY9VeCVJ */
label : _x (
'Excludes' ,
'variations' ,
'woocommerce-admin'
) ,
} ,
] ,
input : {
component : 'Search' ,
type : 'variations' ,
getLabels : getVariationLabels ,
} ,
} ,
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 : _ _ (
2021-08-13 18:54:24 +00:00
'{{title}}Coupon code{{/title}} {{rule /}} {{filter /}}' ,
2020-02-14 02:23:21 +00:00
'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 : {
2021-08-13 18:54:24 +00:00
add : _ _ ( 'Customer type' , 'woocommerce-admin' ) ,
2020-02-14 02:23:21 +00:00
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-09-03 14:08:06 +00:00
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' ,
} ,
} ,
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*/