Skip to content

Commit

Permalink
[#766] Fixing All auctions ordering (#777)
Browse files Browse the repository at this point in the history
* [#766] updating the order for the start date on aucitons

* [#766] defaulting auctions back to bid
  • Loading branch information
nathan-schmidt-viget authored Mar 15, 2024
1 parent f77fc75 commit 817e955
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions client-mu-plugins/goodbids/blocks/all-auctions/block.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,11 @@ private function sort_auctions_by( string $sort, array $auctions = [] ): array {
'starting' => 'calculate_starting_bid',
'ending' => 'get_end_date_time',
'low_bid' => 'bid_variation_price',
'popular' => 'get_watch_count',
default => false,
};

if ( $sort_method ) {
return collect( $auctions )
$auctions = collect( $auctions )
->sortBy(
fn( array $auction_data ) => goodbids()->sites->swap(
function () use ( $auction_data, $sort_method ) {
Expand All @@ -270,8 +269,14 @@ function () use ( $auction_data, $sort_method ) {
},
$auction_data['site_id']
)
)
->all();
);

// if sorting by start date, reverse the auctions
if ( $sort_method === 'get_start_date_time' ) {
$auctions = $auctions->reverse();
}

return $auctions->all();
}

return $auctions;
Expand Down

0 comments on commit 817e955

Please sign in to comment.