Skip to content

Commit 0da1a81

Browse files
authored
feat: filters added to product and order orderby enumerations (#737)
1 parent 80252b0 commit 0da1a81

File tree

2 files changed

+70
-64
lines changed

2 files changed

+70
-64
lines changed

includes/type/enum/class-orders-orderby-enum.php

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,37 @@ class Orders_Orderby_Enum extends Post_Type_Orderby_Enum {
2525
* @return array
2626
*/
2727
protected static function values() {
28-
return array_merge(
29-
self::post_type_values(),
30-
[
31-
'ORDER_KEY' => [
32-
'value' => '_order_key',
33-
'description' => __( 'Order by order key', 'wp-graphql-woocommerce' ),
34-
],
35-
'DISCOUNT' => [
36-
'value' => '_cart_discount',
37-
'description' => __( 'Order by order discount amount', 'wp-graphql-woocommerce' ),
38-
],
39-
'TOTAL' => [
40-
'value' => '_order_total',
41-
'description' => __( 'Order by order total', 'wp-graphql-woocommerce' ),
42-
],
43-
'TAX' => [
44-
'value' => '_order_tax',
45-
'description' => __( 'Order by order total', 'wp-graphql-woocommerce' ),
46-
],
47-
'DATE_PAID' => [
48-
'value' => '_date_paid',
49-
'description' => __( 'Order by date the order was paid', 'wp-graphql-woocommerce' ),
50-
],
51-
'DATE_COMPLETED' => [
52-
'value' => '_date_completed',
53-
'description' => __( 'Order by date the order was completed', 'wp-graphql-woocommerce' ),
54-
],
55-
]
28+
return apply_filters(
29+
'woographql_orderby_enum_values',
30+
array_merge(
31+
self::post_type_values(),
32+
[
33+
'ORDER_KEY' => [
34+
'value' => '_order_key',
35+
'description' => __( 'Order by order key', 'wp-graphql-woocommerce' ),
36+
],
37+
'DISCOUNT' => [
38+
'value' => '_cart_discount',
39+
'description' => __( 'Order by order discount amount', 'wp-graphql-woocommerce' ),
40+
],
41+
'TOTAL' => [
42+
'value' => '_order_total',
43+
'description' => __( 'Order by order total', 'wp-graphql-woocommerce' ),
44+
],
45+
'TAX' => [
46+
'value' => '_order_tax',
47+
'description' => __( 'Order by order total', 'wp-graphql-woocommerce' ),
48+
],
49+
'DATE_PAID' => [
50+
'value' => '_date_paid',
51+
'description' => __( 'Order by date the order was paid', 'wp-graphql-woocommerce' ),
52+
],
53+
'DATE_COMPLETED' => [
54+
'value' => '_date_completed',
55+
'description' => __( 'Order by date the order was completed', 'wp-graphql-woocommerce' ),
56+
],
57+
]
58+
)
5659
);
5760
}
5861
}

includes/type/enum/class-products-orderby-enum.php

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -25,42 +25,45 @@ class Products_Orderby_Enum extends Post_Type_Orderby_Enum {
2525
* @return array
2626
*/
2727
protected static function values() {
28-
return array_merge(
29-
self::post_type_values(),
30-
[
31-
'PRICE' => [
32-
'value' => '_price',
33-
'description' => __( 'Order by product\'s current price', 'wp-graphql-woocommerce' ),
34-
],
35-
'REGULAR_PRICE' => [
36-
'value' => '_regular_price',
37-
'description' => __( 'Order by product\'s regular price', 'wp-graphql-woocommerce' ),
38-
],
39-
'SALE_PRICE' => [
40-
'value' => '_sale_price',
41-
'description' => __( 'Order by product\'s sale price', 'wp-graphql-woocommerce' ),
42-
],
43-
'REVIEW_COUNT' => [
44-
'value' => '_wc_rating_count',
45-
'description' => __( 'Order by number of reviews on product', 'wp-graphql-woocommerce' ),
46-
],
47-
'RATING' => [
48-
'value' => '_wc_average_rating',
49-
'description' => __( 'Order by product average rating', 'wp-graphql-woocommerce' ),
50-
],
51-
'ON_SALE_FROM' => [
52-
'value' => '_sale_price_dates_from',
53-
'description' => __( 'Order by date product sale starts', 'wp-graphql-woocommerce' ),
54-
],
55-
'ON_SALE_TO' => [
56-
'value' => '_sale_price_dates_to',
57-
'description' => __( 'Order by date product sale ends', 'wp-graphql-woocommerce' ),
58-
],
59-
'TOTAL_SALES' => [
60-
'value' => 'total_sales',
61-
'description' => __( 'Order by total sales of products sold', 'wp-graphql-woocommerce' ),
62-
],
63-
]
28+
return apply_filters(
29+
'woographql_product_orderby_enum_values',
30+
array_merge(
31+
self::post_type_values(),
32+
[
33+
'PRICE' => [
34+
'value' => '_price',
35+
'description' => __( 'Order by product\'s current price', 'wp-graphql-woocommerce' ),
36+
],
37+
'REGULAR_PRICE' => [
38+
'value' => '_regular_price',
39+
'description' => __( 'Order by product\'s regular price', 'wp-graphql-woocommerce' ),
40+
],
41+
'SALE_PRICE' => [
42+
'value' => '_sale_price',
43+
'description' => __( 'Order by product\'s sale price', 'wp-graphql-woocommerce' ),
44+
],
45+
'REVIEW_COUNT' => [
46+
'value' => '_wc_rating_count',
47+
'description' => __( 'Order by number of reviews on product', 'wp-graphql-woocommerce' ),
48+
],
49+
'RATING' => [
50+
'value' => '_wc_average_rating',
51+
'description' => __( 'Order by product average rating', 'wp-graphql-woocommerce' ),
52+
],
53+
'ON_SALE_FROM' => [
54+
'value' => '_sale_price_dates_from',
55+
'description' => __( 'Order by date product sale starts', 'wp-graphql-woocommerce' ),
56+
],
57+
'ON_SALE_TO' => [
58+
'value' => '_sale_price_dates_to',
59+
'description' => __( 'Order by date product sale ends', 'wp-graphql-woocommerce' ),
60+
],
61+
'TOTAL_SALES' => [
62+
'value' => 'total_sales',
63+
'description' => __( 'Order by total sales of products sold', 'wp-graphql-woocommerce' ),
64+
],
65+
]
66+
)
6467
);
6568
}
6669
}

0 commit comments

Comments
 (0)