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' ,
2022-03-30 09:00:04 +00:00
label : _ _ ( 'Orders' , 'woocommerce' ) ,
2018-11-07 16:38:34 +00:00
type : 'number' ,
} ,
{
key : 'net_revenue' ,
2022-03-30 09:00:04 +00:00
label : _ _ ( 'Net sales' , 'woocommerce' ) ,
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' ,
2022-03-30 09:00:04 +00:00
label : _ _ ( 'Average order value' , 'woocommerce' ) ,
2018-11-07 16:38:34 +00:00
type : 'currency' ,
} ,
{
key : 'avg_items_per_order' ,
2022-03-30 09:00:04 +00:00
label : _ _ ( 'Average items per order' , 'woocommerce' ) ,
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
{
2022-03-30 09:00:04 +00:00
label : _ _ ( 'Show' , 'woocommerce' ) ,
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 : [
2022-03-30 09:00:04 +00:00
{ label : _ _ ( 'All orders' , 'woocommerce' ) , value : 'all' } ,
2020-02-14 02:23:21 +00:00
{
2022-03-30 09:00:04 +00:00
label : _ _ ( 'Advanced filters' , 'woocommerce' ) ,
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
2022-03-18 11:45:14 +00:00
* @ param { Object } advancedFilters Report Advanced Filters .
* @ param { string } advancedFilters . title Interpolated component string for Advanced Filters title .
2022-02-11 14:38:38 +00:00
* @ 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' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-02-14 02:23:21 +00:00
) ,
filters : {
status : {
labels : {
2022-03-30 09:00:04 +00:00
add : _ _ ( 'Order Status' , 'woocommerce' ) ,
remove : _ _ ( 'Remove order status filter' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
rule : _ _ (
'Select an order status filter match' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-02-14 02:23:21 +00:00
) ,
/* translators: A sentence describing an Order Status filter. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ */
title : _ _ (
'{{title}}Order Status{{/title}} {{rule /}} {{filter /}}' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-02-14 02:23:21 +00:00
) ,
2022-03-30 09:00:04 +00:00
filter : _ _ ( 'Select an order status' , 'woocommerce' ) ,
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 */
2022-03-30 09:00:04 +00:00
label : _x ( 'Is' , 'order status' , 'woocommerce' ) ,
2020-02-14 02:23:21 +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 */
2022-03-30 09:00:04 +00:00
label : _x ( 'Is Not' , 'order status' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
} ,
] ,
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 : {
2022-03-30 09:00:04 +00:00
add : _ _ ( 'Products' , 'woocommerce' ) ,
placeholder : _ _ ( 'Search products' , 'woocommerce' ) ,
remove : _ _ ( 'Remove products filter' , 'woocommerce' ) ,
rule : _ _ ( 'Select a product filter match' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
/* translators: A sentence describing a Product filter. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ */
title : _ _ (
'{{title}}Product{{/title}} {{rule /}} {{filter /}}' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-02-14 02:23:21 +00:00
) ,
2022-03-30 09:00:04 +00:00
filter : _ _ ( 'Select products' , 'woocommerce' ) ,
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 */
2022-03-30 09:00:04 +00:00
label : _x ( 'Includes' , 'products' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
} ,
{
value : 'excludes' ,
/* translators: Sentence fragment, logical, "Excludes" refers to orders excluding a given product(s). Screenshot for context: https://cloudup.com/cSsUY9VeCVJ */
2022-03-30 09:00:04 +00:00
label : _x ( 'Excludes' , 'products' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
} ,
] ,
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 : {
2022-03-30 09:00:04 +00:00
add : _ _ ( 'Variations' , 'woocommerce' ) ,
placeholder : _ _ ( 'Search variations' , 'woocommerce' ) ,
remove : _ _ ( 'Remove variations filter' , 'woocommerce' ) ,
2020-09-25 13:57:48 +00:00
rule : _ _ (
'Select a variation filter match' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-09-25 13:57:48 +00:00
) ,
/* translators: A sentence describing a Variation filter. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ */
title : _ _ (
'{{title}}Variation{{/title}} {{rule /}} {{filter /}}' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-09-25 13:57:48 +00:00
) ,
2022-03-30 09:00:04 +00:00
filter : _ _ ( 'Select variation' , 'woocommerce' ) ,
2020-09-25 13:57:48 +00:00
} ,
rules : [
{
value : 'includes' ,
/* translators: Sentence fragment, logical, "Includes" refers to orders including a given variation(s). Screenshot for context: https://cloudup.com/cSsUY9VeCVJ */
2022-03-30 09:00:04 +00:00
label : _x ( 'Includes' , 'variations' , 'woocommerce' ) ,
2020-09-25 13:57:48 +00:00
} ,
{
value : 'excludes' ,
/* translators: Sentence fragment, logical, "Excludes" refers to orders excluding a given variation(s). Screenshot for context: https://cloudup.com/cSsUY9VeCVJ */
2022-03-30 09:00:04 +00:00
label : _x ( 'Excludes' , 'variations' , 'woocommerce' ) ,
2020-09-25 13:57:48 +00:00
} ,
] ,
input : {
component : 'Search' ,
type : 'variations' ,
getLabels : getVariationLabels ,
} ,
} ,
2020-02-14 02:23:21 +00:00
coupon : {
labels : {
2022-03-30 09:00:04 +00:00
add : _ _ ( 'Coupon Codes' , 'woocommerce' ) ,
placeholder : _ _ ( 'Search coupons' , 'woocommerce' ) ,
remove : _ _ ( 'Remove coupon filter' , 'woocommerce' ) ,
rule : _ _ ( 'Select a coupon filter match' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
/* 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 /}}' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-02-14 02:23:21 +00:00
) ,
2022-03-30 09:00:04 +00:00
filter : _ _ ( 'Select coupon codes' , 'woocommerce' ) ,
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 */
2022-03-30 09:00:04 +00:00
label : _x ( 'Includes' , 'coupon code' , 'woocommerce' ) ,
2020-02-14 02:23:21 +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 */
2022-03-30 09:00:04 +00:00
label : _x ( 'Excludes' , 'coupon code' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
} ,
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 : {
2022-03-30 09:00:04 +00:00
add : _ _ ( 'Customer type' , 'woocommerce' ) ,
remove : _ _ ( 'Remove customer filter' , 'woocommerce' ) ,
rule : _ _ ( 'Select a customer filter match' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
/* translators: A sentence describing a Customer filter. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ */
title : _ _ (
'{{title}}Customer is{{/title}} {{filter /}}' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-02-14 02:23:21 +00:00
) ,
2022-03-30 09:00:04 +00:00
filter : _ _ ( 'Select a customer type' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
} ,
input : {
component : 'SelectControl' ,
options : [
{
value : 'new' ,
2022-03-30 09:00:04 +00:00
label : _ _ ( 'New' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
} ,
{
value : 'returning' ,
2022-03-30 09:00:04 +00:00
label : _ _ ( 'Returning' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
} ,
] ,
defaultOption : 'new' ,
} ,
2019-05-10 06:56:57 +00:00
} ,
2020-02-14 02:23:21 +00:00
refunds : {
labels : {
2022-03-30 09:00:04 +00:00
add : _ _ ( 'Refunds' , 'woocommerce' ) ,
remove : _ _ ( 'Remove refunds filter' , 'woocommerce' ) ,
rule : _ _ ( 'Select a refund filter match' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
title : _ _ (
'{{title}}Refunds{{/title}} {{filter /}}' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-02-14 02:23:21 +00:00
) ,
2022-03-30 09:00:04 +00:00
filter : _ _ ( 'Select a refund type' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
} ,
input : {
component : 'SelectControl' ,
options : [
{
value : 'all' ,
2022-03-30 09:00:04 +00:00
label : _ _ ( 'All' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
} ,
{
value : 'partial' ,
2022-03-30 09:00:04 +00:00
label : _ _ ( 'Partially refunded' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
} ,
{
value : 'full' ,
2022-03-30 09:00:04 +00:00
label : _ _ ( 'Fully refunded' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
} ,
{
value : 'none' ,
2022-03-30 09:00:04 +00:00
label : _ _ ( 'None' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
} ,
] ,
defaultOption : 'all' ,
} ,
2019-11-13 03:22:06 +00:00
} ,
2020-02-14 02:23:21 +00:00
tax _rate : {
labels : {
2022-03-30 09:00:04 +00:00
add : _ _ ( 'Tax Rates' , 'woocommerce' ) ,
placeholder : _ _ ( 'Search tax rates' , 'woocommerce' ) ,
remove : _ _ ( 'Remove tax rate filter' , 'woocommerce' ) ,
rule : _ _ ( 'Select a tax rate filter match' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
/* translators: A sentence describing a tax rate filter. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ */
title : _ _ (
'{{title}}Tax Rate{{/title}} {{rule /}} {{filter /}}' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-02-14 02:23:21 +00:00
) ,
2022-03-30 09:00:04 +00:00
filter : _ _ ( 'Select tax rates' , 'woocommerce' ) ,
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 */
2022-03-30 09:00:04 +00:00
label : _x ( 'Includes' , 'tax rate' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
} ,
{
value : 'excludes' ,
/* translators: Sentence fragment, logical, "Excludes" refers to orders excluding a given tax rate(s). Screenshot for context: https://cloudup.com/cSsUY9VeCVJ */
2022-03-30 09:00:04 +00:00
label : _x ( 'Excludes' , 'tax rate' , 'woocommerce' ) ,
2020-02-14 02:23:21 +00:00
} ,
] ,
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 : {
2022-03-30 09:00:04 +00:00
add : _ _ ( 'Attribute' , 'woocommerce' ) ,
placeholder : _ _ ( 'Search attributes' , 'woocommerce' ) ,
remove : _ _ ( 'Remove attribute filter' , 'woocommerce' ) ,
2020-09-03 14:08:06 +00:00
rule : _ _ (
'Select a product attribute filter match' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-09-03 14:08:06 +00:00
) ,
/* translators: A sentence describing a Product filter. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ */
title : _ _ (
'{{title}}Attribute{{/title}} {{rule /}} {{filter /}}' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-09-03 14:08:06 +00:00
) ,
2022-03-30 09:00:04 +00:00
filter : _ _ ( 'Select attributes' , 'woocommerce' ) ,
2020-09-03 14:08:06 +00:00
} ,
rules : [
{
value : 'is' ,
/* translators: Sentence fragment, logical, "Is" refers to searching for products matching a chosen attribute. Screenshot for context: https://cloudup.com/cSsUY9VeCVJ */
2022-03-30 09:00:04 +00:00
label : _x ( 'Is' , 'product attribute' , 'woocommerce' ) ,
2020-09-03 14:08:06 +00:00
} ,
{
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' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-09-03 14:08:06 +00:00
) ,
} ,
] ,
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*/