2020-09-25 13:57:48 +00:00
/ * *
* External dependencies
* /
import { _ _ , _x } from '@wordpress/i18n' ;
import { applyFilters } from '@wordpress/hooks' ;
2021-04-22 20:06:46 +00:00
import { dispatch } from '@wordpress/data' ;
2023-03-16 14:22:33 +00:00
import { STORE _KEY as CES _STORE _KEY } from '@woocommerce/customer-effort-score' ;
2020-09-25 13:57:48 +00:00
/ * *
* Internal dependencies
* /
import {
getCategoryLabels ,
getProductLabels ,
getVariationLabels ,
} from '../../../lib/async-requests' ;
const VARIATIONS _REPORT _CHARTS _FILTER =
'woocommerce_admin_variations_report_charts' ;
const VARIATIONS _REPORT _FILTERS _FILTER =
'woocommerce_admin_variations_report_filters' ;
const VARIATIONS _REPORT _ADVANCED _FILTERS _FILTER =
'woocommerce_admin_variations_report_advanced_filters' ;
2021-04-22 20:06:46 +00:00
const { addCesSurveyForAnalytics } = dispatch ( CES _STORE _KEY ) ;
2022-02-11 14:38:38 +00:00
/ * *
* @ typedef { import ( '../index.js' ) . chart } chart
* /
/ * *
* Variations Report charts filter .
*
* @ filter woocommerce _admin _variations _report _charts
* @ param { Array . < chart > } charts Report charts .
* /
2020-09-25 13:57:48 +00:00
export const charts = applyFilters ( VARIATIONS _REPORT _CHARTS _FILTER , [
{
key : 'items_sold' ,
2022-03-30 09:00:04 +00:00
label : _ _ ( 'Items sold' , 'woocommerce' ) ,
2020-09-25 13:57:48 +00:00
order : 'desc' ,
orderby : 'items_sold' ,
type : 'number' ,
} ,
{
key : 'net_revenue' ,
2022-03-30 09:00:04 +00:00
label : _ _ ( 'Net sales' , 'woocommerce' ) ,
2020-09-25 13:57:48 +00:00
order : 'desc' ,
orderby : 'net_revenue' ,
type : 'currency' ,
} ,
{
key : 'orders_count' ,
2022-03-30 09:00:04 +00:00
label : _ _ ( 'Orders' , 'woocommerce' ) ,
2020-09-25 13:57:48 +00:00
order : 'desc' ,
orderby : 'orders_count' ,
type : 'number' ,
} ,
] ) ;
2022-02-11 14:38:38 +00:00
/ * *
* @ typedef { import ( '../index.js' ) . filter } filter
* /
/ * *
* Variations Report Filters .
*
* @ filter woocommerce _admin _variations _report _filters
* @ param { Array . < filter > } filters Report filters .
* /
2020-09-25 13:57:48 +00:00
export const filters = applyFilters ( VARIATIONS _REPORT _FILTERS _FILTER , [
{
2022-03-30 09:00:04 +00:00
label : _ _ ( 'Show' , 'woocommerce' ) ,
2020-09-25 13:57:48 +00:00
staticParams : [ 'chartType' , 'paged' , 'per_page' ] ,
param : 'filter-variations' ,
showFilters : ( ) => true ,
filters : [
{
2022-03-30 09:00:04 +00:00
label : _ _ ( 'All variations' , 'woocommerce' ) ,
2020-09-25 13:57:48 +00:00
chartMode : 'item-comparison' ,
value : 'all' ,
} ,
{
2022-03-30 09:00:04 +00:00
label : _ _ ( 'Single variation' , 'woocommerce' ) ,
2020-09-25 13:57:48 +00:00
value : 'select_variation' ,
subFilters : [
{
component : 'Search' ,
value : 'single_variation' ,
path : [ 'select_variation' ] ,
settings : {
type : 'variations' ,
param : 'variations' ,
getLabels : getVariationLabels ,
labels : {
placeholder : _ _ (
'Type to search for a variation' ,
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
button : _ _ ( 'Single variation' , 'woocommerce' ) ,
2020-09-25 13:57:48 +00:00
} ,
} ,
} ,
] ,
} ,
{
2022-03-30 09:00:04 +00:00
label : _ _ ( 'Comparison' , 'woocommerce' ) ,
2020-09-25 13:57:48 +00:00
chartMode : 'item-comparison' ,
value : 'compare-variations' ,
settings : {
type : 'variations' ,
param : 'variations' ,
getLabels : getVariationLabels ,
labels : {
helpText : _ _ (
'Check at least two variations below to compare' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-09-25 13:57:48 +00:00
) ,
placeholder : _ _ (
'Search for variations to compare' ,
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
title : _ _ ( 'Compare Variations' , 'woocommerce' ) ,
update : _ _ ( 'Compare' , 'woocommerce' ) ,
2020-09-25 13:57:48 +00:00
} ,
2021-04-22 20:06:46 +00:00
onClick : addCesSurveyForAnalytics ,
2020-09-25 13:57:48 +00:00
} ,
} ,
{
2022-03-30 09:00:04 +00:00
label : _ _ ( 'Advanced filters' , 'woocommerce' ) ,
2020-09-25 13:57:48 +00:00
value : 'advanced' ,
} ,
] ,
} ,
] ) ;
2022-02-11 14:38:38 +00:00
/ * *
* Variations Report Advanced Filters .
*
* @ filter woocommerce _admin _variations _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-09-25 13:57:48 +00:00
export const advancedFilters = applyFilters (
VARIATIONS _REPORT _ADVANCED _FILTERS _FILTER ,
{
title : _x (
2023-04-26 10:58:14 +00:00
'Variations match <select/> filters' ,
2020-09-25 13:57:48 +00:00
'A sentence describing filters for Variations. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-09-25 13:57:48 +00:00
) ,
filters : {
attribute : {
allowMultiple : true ,
labels : {
2024-05-02 10:34:17 +00:00
add : _ _ ( 'Product attribute' , 'woocommerce' ) ,
placeholder : _ _ (
'Search product attributes' ,
'woocommerce'
) ,
remove : _ _ (
'Remove product attribute filter' ,
'woocommerce'
) ,
2020-09-25 13:57:48 +00:00
rule : _ _ (
'Select a product attribute filter match' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-09-25 13:57:48 +00:00
) ,
/* translators: A sentence describing a Product filter. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ */
title : _ _ (
2024-05-02 10:34:17 +00:00
'<title>Product attribute</title> <rule/> <filter/>' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-09-25 13:57:48 +00:00
) ,
2024-05-02 10:34:17 +00:00
filter : _ _ ( 'Select product attributes' , 'woocommerce' ) ,
2020-09-25 13:57:48 +00:00
} ,
rules : [
{
value : 'is' ,
/* translators: Sentence fragment, logical, "Is" refers to searching for product variations 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-25 13:57:48 +00:00
} ,
{
value : 'is_not' ,
/* translators: Sentence fragment, logical, "Is Not" refers to searching for product variations 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-25 13:57:48 +00:00
) ,
} ,
] ,
input : {
component : 'ProductAttribute' ,
} ,
} ,
category : {
labels : {
2024-05-02 10:34:17 +00:00
add : _ _ ( 'Product category' , 'woocommerce' ) ,
placeholder : _ _ (
'Search product categories' ,
'woocommerce'
) ,
remove : _ _ (
'Remove product category filter' ,
'woocommerce'
) ,
rule : _ _ (
'Select a product category filter match' ,
'woocommerce'
) ,
2020-09-25 13:57:48 +00:00
/* translators: A sentence describing a Category filter. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ */
title : _ _ (
2024-05-02 10:34:17 +00:00
'<title>Product category</title> <rule/> <filter/>' ,
2022-03-30 09:00:04 +00:00
'woocommerce'
2020-09-25 13:57:48 +00:00
) ,
2024-05-02 10:34:17 +00:00
filter : _ _ ( 'Select product categories' , 'woocommerce' ) ,
2020-09-25 13:57:48 +00:00
} ,
rules : [
{
value : 'includes' ,
/* translators: Sentence fragment, logical, "Includes" refers to variations including a given category. Screenshot for context: https://cloudup.com/cSsUY9VeCVJ */
2022-03-30 09:00:04 +00:00
label : _x ( 'Includes' , 'categories' , 'woocommerce' ) ,
2020-09-25 13:57:48 +00:00
} ,
{
value : 'excludes' ,
/* translators: Sentence fragment, logical, "Excludes" refers to variations excluding a given category. Screenshot for context: https://cloudup.com/cSsUY9VeCVJ */
2022-03-30 09:00:04 +00:00
label : _x ( 'Excludes' , 'categories' , 'woocommerce' ) ,
2020-09-25 13:57:48 +00:00
} ,
] ,
input : {
component : 'Search' ,
type : 'categories' ,
getLabels : getCategoryLabels ,
} ,
} ,
product : {
labels : {
2024-05-02 10:34:17 +00:00
add : _ _ ( 'Product' , 'woocommerce' ) ,
2022-03-30 09:00:04 +00:00
placeholder : _ _ ( 'Search products' , 'woocommerce' ) ,
2024-05-02 10:34:17 +00:00
remove : _ _ ( 'Remove product filter' , 'woocommerce' ) ,
2022-03-30 09:00:04 +00:00
rule : _ _ ( 'Select a product filter match' , 'woocommerce' ) ,
2020-09-25 13:57:48 +00:00
/* translators: A sentence describing a Product filter. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ */
title : _ _ (
2023-04-26 10:58:14 +00:00
'<title>Product</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 products' , 'woocommerce' ) ,
2020-09-25 13:57:48 +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-09-25 13:57:48 +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-09-25 13:57:48 +00:00
} ,
] ,
input : {
component : 'Search' ,
type : 'variableProducts' ,
getLabels : getProductLabels ,
} ,
} ,
} ,
}
) ;