Skip to content

Commit

Permalink
feat: filters added to product and order orderby enumerations (#737)
Browse files Browse the repository at this point in the history
  • Loading branch information
kidunot89 committed Apr 21, 2023
1 parent 80252b0 commit 0da1a81
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 64 deletions.
59 changes: 31 additions & 28 deletions includes/type/enum/class-orders-orderby-enum.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,37 @@ class Orders_Orderby_Enum extends Post_Type_Orderby_Enum {
* @return array
*/
protected static function values() {
return array_merge(
self::post_type_values(),
[
'ORDER_KEY' => [
'value' => '_order_key',
'description' => __( 'Order by order key', 'wp-graphql-woocommerce' ),
],
'DISCOUNT' => [
'value' => '_cart_discount',
'description' => __( 'Order by order discount amount', 'wp-graphql-woocommerce' ),
],
'TOTAL' => [
'value' => '_order_total',
'description' => __( 'Order by order total', 'wp-graphql-woocommerce' ),
],
'TAX' => [
'value' => '_order_tax',
'description' => __( 'Order by order total', 'wp-graphql-woocommerce' ),
],
'DATE_PAID' => [
'value' => '_date_paid',
'description' => __( 'Order by date the order was paid', 'wp-graphql-woocommerce' ),
],
'DATE_COMPLETED' => [
'value' => '_date_completed',
'description' => __( 'Order by date the order was completed', 'wp-graphql-woocommerce' ),
],
]
return apply_filters(
'woographql_orderby_enum_values',
array_merge(
self::post_type_values(),
[
'ORDER_KEY' => [
'value' => '_order_key',
'description' => __( 'Order by order key', 'wp-graphql-woocommerce' ),
],
'DISCOUNT' => [
'value' => '_cart_discount',
'description' => __( 'Order by order discount amount', 'wp-graphql-woocommerce' ),
],
'TOTAL' => [
'value' => '_order_total',
'description' => __( 'Order by order total', 'wp-graphql-woocommerce' ),
],
'TAX' => [
'value' => '_order_tax',
'description' => __( 'Order by order total', 'wp-graphql-woocommerce' ),
],
'DATE_PAID' => [
'value' => '_date_paid',
'description' => __( 'Order by date the order was paid', 'wp-graphql-woocommerce' ),
],
'DATE_COMPLETED' => [
'value' => '_date_completed',
'description' => __( 'Order by date the order was completed', 'wp-graphql-woocommerce' ),
],
]
)
);
}
}
75 changes: 39 additions & 36 deletions includes/type/enum/class-products-orderby-enum.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,45 @@ class Products_Orderby_Enum extends Post_Type_Orderby_Enum {
* @return array
*/
protected static function values() {
return array_merge(
self::post_type_values(),
[
'PRICE' => [
'value' => '_price',
'description' => __( 'Order by product\'s current price', 'wp-graphql-woocommerce' ),
],
'REGULAR_PRICE' => [
'value' => '_regular_price',
'description' => __( 'Order by product\'s regular price', 'wp-graphql-woocommerce' ),
],
'SALE_PRICE' => [
'value' => '_sale_price',
'description' => __( 'Order by product\'s sale price', 'wp-graphql-woocommerce' ),
],
'REVIEW_COUNT' => [
'value' => '_wc_rating_count',
'description' => __( 'Order by number of reviews on product', 'wp-graphql-woocommerce' ),
],
'RATING' => [
'value' => '_wc_average_rating',
'description' => __( 'Order by product average rating', 'wp-graphql-woocommerce' ),
],
'ON_SALE_FROM' => [
'value' => '_sale_price_dates_from',
'description' => __( 'Order by date product sale starts', 'wp-graphql-woocommerce' ),
],
'ON_SALE_TO' => [
'value' => '_sale_price_dates_to',
'description' => __( 'Order by date product sale ends', 'wp-graphql-woocommerce' ),
],
'TOTAL_SALES' => [
'value' => 'total_sales',
'description' => __( 'Order by total sales of products sold', 'wp-graphql-woocommerce' ),
],
]
return apply_filters(
'woographql_product_orderby_enum_values',
array_merge(
self::post_type_values(),
[
'PRICE' => [
'value' => '_price',
'description' => __( 'Order by product\'s current price', 'wp-graphql-woocommerce' ),
],
'REGULAR_PRICE' => [
'value' => '_regular_price',
'description' => __( 'Order by product\'s regular price', 'wp-graphql-woocommerce' ),
],
'SALE_PRICE' => [
'value' => '_sale_price',
'description' => __( 'Order by product\'s sale price', 'wp-graphql-woocommerce' ),
],
'REVIEW_COUNT' => [
'value' => '_wc_rating_count',
'description' => __( 'Order by number of reviews on product', 'wp-graphql-woocommerce' ),
],
'RATING' => [
'value' => '_wc_average_rating',
'description' => __( 'Order by product average rating', 'wp-graphql-woocommerce' ),
],
'ON_SALE_FROM' => [
'value' => '_sale_price_dates_from',
'description' => __( 'Order by date product sale starts', 'wp-graphql-woocommerce' ),
],
'ON_SALE_TO' => [
'value' => '_sale_price_dates_to',
'description' => __( 'Order by date product sale ends', 'wp-graphql-woocommerce' ),
],
'TOTAL_SALES' => [
'value' => 'total_sales',
'description' => __( 'Order by total sales of products sold', 'wp-graphql-woocommerce' ),
],
]
)
);
}
}

0 comments on commit 0da1a81

Please sign in to comment.