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' ;
2020-09-25 13:57:48 +00:00
/ * *
* Internal dependencies
* /
import {
getCategoryLabels ,
getProductLabels ,
getVariationLabels ,
} from '../../../lib/async-requests' ;
2021-04-22 20:06:46 +00:00
import { STORE _KEY as CES _STORE _KEY } from '../../../customer-effort-score-tracks/data/constants' ;
2020-09-25 13:57:48 +00:00
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' ,
2021-08-13 18:54:24 +00:00
label : _ _ ( 'Items sold' , 'woocommerce-admin' ) ,
2020-09-25 13:57:48 +00:00
order : 'desc' ,
orderby : 'items_sold' ,
type : 'number' ,
} ,
{
key : 'net_revenue' ,
2021-08-13 18:54:24 +00:00
label : _ _ ( 'Net sales' , 'woocommerce-admin' ) ,
2020-09-25 13:57:48 +00:00
order : 'desc' ,
orderby : 'net_revenue' ,
type : 'currency' ,
} ,
{
key : 'orders_count' ,
label : _ _ ( 'Orders' , 'woocommerce-admin' ) ,
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 , [
{
label : _ _ ( 'Show' , 'woocommerce-admin' ) ,
staticParams : [ 'chartType' , 'paged' , 'per_page' ] ,
param : 'filter-variations' ,
showFilters : ( ) => true ,
filters : [
{
2021-08-13 18:54:24 +00:00
label : _ _ ( 'All variations' , 'woocommerce-admin' ) ,
2020-09-25 13:57:48 +00:00
chartMode : 'item-comparison' ,
value : 'all' ,
} ,
{
2021-08-13 18:54:24 +00:00
label : _ _ ( 'Single variation' , 'woocommerce-admin' ) ,
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' ,
'woocommerce-admin'
) ,
button : _ _ (
2021-08-13 18:54:24 +00:00
'Single variation' ,
2020-09-25 13:57:48 +00:00
'woocommerce-admin'
) ,
} ,
} ,
} ,
] ,
} ,
{
label : _ _ ( 'Comparison' , 'woocommerce-admin' ) ,
chartMode : 'item-comparison' ,
value : 'compare-variations' ,
settings : {
type : 'variations' ,
param : 'variations' ,
getLabels : getVariationLabels ,
labels : {
helpText : _ _ (
'Check at least two variations below to compare' ,
'woocommerce-admin'
) ,
placeholder : _ _ (
'Search for variations to compare' ,
'woocommerce-admin'
) ,
title : _ _ ( 'Compare Variations' , 'woocommerce-admin' ) ,
update : _ _ ( 'Compare' , 'woocommerce-admin' ) ,
} ,
2021-04-22 20:06:46 +00:00
onClick : addCesSurveyForAnalytics ,
2020-09-25 13:57:48 +00:00
} ,
} ,
{
2021-08-13 18:54:24 +00:00
label : _ _ ( 'Advanced filters' , 'woocommerce-admin' ) ,
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
* @ 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-09-25 13:57:48 +00:00
export const advancedFilters = applyFilters (
VARIATIONS _REPORT _ADVANCED _FILTERS _FILTER ,
{
title : _x (
2021-08-13 18:54:24 +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' ,
'woocommerce-admin'
) ,
filters : {
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 product variations 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 product variations 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' ,
} ,
} ,
category : {
labels : {
add : _ _ ( 'Categories' , 'woocommerce-admin' ) ,
placeholder : _ _ ( 'Search categories' , 'woocommerce-admin' ) ,
remove : _ _ (
'Remove categories filter' ,
'woocommerce-admin'
) ,
rule : _ _ (
'Select a category filter match' ,
'woocommerce-admin'
) ,
/* translators: A sentence describing a Category filter. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ */
title : _ _ (
'{{title}}Category{{/title}} {{rule /}} {{filter /}}' ,
'woocommerce-admin'
) ,
filter : _ _ ( 'Select categories' , 'woocommerce-admin' ) ,
} ,
rules : [
{
value : 'includes' ,
/* translators: Sentence fragment, logical, "Includes" refers to variations including a given category. Screenshot for context: https://cloudup.com/cSsUY9VeCVJ */
label : _x (
'Includes' ,
'categories' ,
'woocommerce-admin'
) ,
} ,
{
value : 'excludes' ,
/* translators: Sentence fragment, logical, "Excludes" refers to variations excluding a given category. Screenshot for context: https://cloudup.com/cSsUY9VeCVJ */
label : _x (
'Excludes' ,
'categories' ,
'woocommerce-admin'
) ,
} ,
] ,
input : {
component : 'Search' ,
type : 'categories' ,
getLabels : getCategoryLabels ,
} ,
} ,
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' ) ,
} ,
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 : 'variableProducts' ,
getLabels : getProductLabels ,
} ,
} ,
} ,
}
) ;