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,
},
query: {
orderBy: 'date',
orderBy: 'post__in',
order: 'desc',
perPage: 5,
pages: 1,

View File

@ -44,7 +44,7 @@ class ProductCollection extends AbstractBlock {
*
* @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,
array(
'orderby' => $orderby,
'post__in' => $handpicked_products,
'on_sale' => $on_sale,
'stock_status' => $stock_status,
'product_attributes' => $product_attributes,
@ -706,7 +707,7 @@ class ProductCollection extends AbstractBlock {
'posts_per_page' => $query['perPage'],
'order' => $query['order'],
'offset' => ( $per_page * ( $page - 1 ) ) + $offset,
'post__in' => array(),
'post__in' => $query['woocommerceHandPickedProducts'] ?? array(),
'post_status' => 'publish',
'post_type' => 'product',
// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query