Improve the query merging logic

This commit is contained in:
Bart Kalisz 2024-09-11 18:32:22 +02:00 committed by Christopher Allford
parent 2690191cbe
commit 31775d6835
No known key found for this signature in database
GPG Key ID: 80E44C778F08A88E
2 changed files with 2 additions and 4 deletions

View File

@ -62,7 +62,6 @@ const attributes = {
},
query: {
orderBy: 'post__in',
order: 'desc',
perPage: 5,
pages: 1,
},

View File

@ -55,7 +55,6 @@ class ProductCollection extends AbstractBlock {
*/
protected $custom_order_opts = array( 'popularity', 'rating', 'post__in' );
/**
* The render state of the product collection block.
*
@ -1012,7 +1011,7 @@ class ProductCollection extends AbstractBlock {
* @return array
*/
private function get_custom_orderby_query( $orderby ) {
if ( ! in_array( $orderby, $this->custom_order_opts, true ) ) {
if ( ! in_array( $orderby, $this->custom_order_opts, true ) || 'post__in' === $orderby ) {
return array( 'orderby' => $orderby );
}