Improve the query merging logic
This commit is contained in:
parent
2690191cbe
commit
31775d6835
|
@ -62,7 +62,6 @@ const attributes = {
|
|||
},
|
||||
query: {
|
||||
orderBy: 'post__in',
|
||||
order: 'desc',
|
||||
perPage: 5,
|
||||
pages: 1,
|
||||
},
|
||||
|
|
|
@ -19,7 +19,7 @@ class ProductCollection extends AbstractBlock {
|
|||
*/
|
||||
protected $block_name = 'product-collection';
|
||||
|
||||
/**
|
||||
/**
|
||||
* An associative array of collection handlers.
|
||||
*
|
||||
* @var array<string, callable> $collection_handler_store
|
||||
|
@ -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 );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue