Enable sorting by entered order

This commit is contained in:
Bart Kalisz 2024-09-10 16:10:42 +02:00
parent a1a23f32d4
commit f6d040915d
2 changed files with 4 additions and 3 deletions

View File

@ -61,7 +61,7 @@ const attributes = {
shrinkColumns: true, shrinkColumns: true,
}, },
query: { query: {
orderBy: 'date', orderBy: 'post__in',
order: 'desc', order: 'desc',
perPage: 5, perPage: 5,
pages: 1, pages: 1,

View File

@ -44,7 +44,7 @@ class ProductCollection extends AbstractBlock {
* *
* @var array * @var array
*/ */
protected $custom_order_opts = array( 'popularity', 'rating' ); protected $custom_order_opts = array( 'popularity', 'rating', 'post__in' );
/** /**
@ -620,6 +620,7 @@ class ProductCollection extends AbstractBlock {
$args, $args,
array( array(
'orderby' => $orderby, 'orderby' => $orderby,
'post__in' => $handpicked_products,
'on_sale' => $on_sale, 'on_sale' => $on_sale,
'stock_status' => $stock_status, 'stock_status' => $stock_status,
'product_attributes' => $product_attributes, 'product_attributes' => $product_attributes,
@ -706,7 +707,7 @@ class ProductCollection extends AbstractBlock {
'posts_per_page' => $query['perPage'], 'posts_per_page' => $query['perPage'],
'order' => $query['order'], 'order' => $query['order'],
'offset' => ( $per_page * ( $page - 1 ) ) + $offset, 'offset' => ( $per_page * ( $page - 1 ) ) + $offset,
'post__in' => array(), 'post__in' => $query['woocommerceHandPickedProducts'] ?? array(),
'post_status' => 'publish', 'post_status' => 'publish',
'post_type' => 'product', 'post_type' => 'product',
// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query