From decea3d28c5bc745518cff794e696cb70a884f84 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Thu, 1 Aug 2019 15:55:32 -0300 Subject: [PATCH] Allow sort products by "include" order --- includes/data-stores/class-wc-product-data-store-cpt.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/data-stores/class-wc-product-data-store-cpt.php b/includes/data-stores/class-wc-product-data-store-cpt.php index 61d765c35bf..811c15a63b6 100644 --- a/includes/data-stores/class-wc-product-data-store-cpt.php +++ b/includes/data-stores/class-wc-product-data-store-cpt.php @@ -1958,6 +1958,11 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da add_filter( 'posts_where', array( $this, 'reviews_allowed_query_where' ), 10, 2 ); } + // Handle orderby. + if ( isset( $query_vars['orderby'] ) && 'include' === $query_vars['orderby'] ) { + $wp_query_args['orderby'] = 'post__in'; + } + return apply_filters( 'woocommerce_product_data_store_cpt_get_products_query', $wp_query_args, $query_vars, $this ); }