Lesson 107: Keeping Recently Closed Auctions Visible on the Frontend

One challenge with any auction platform is deciding what happens when an auction ends. If completed auctions disappear immediately, visitors have no way to verify the final outcome or learn from previous listings. On the other hand, displaying every completed auction forever eventually clutters the marketplace.

In this lesson, we improve the Flipnzee Auctions plugin by introducing a configurable auction history retention period. Recently closed auctions remain visible for a limited number of days before being automatically removed from the main auction listing.


Why This Improvement?

Previously, the frontend displayed only active auctions.

This created a poor user experience because:

  • Users could not verify the result of an auction after it ended.
  • Winning bidders had no convenient way to revisit their completed auction.
  • Visitors could not see whether a reserve price had been met.
  • Auctions disappeared immediately after completion.

Our goal was to provide a short auction history while keeping the homepage clean.


Defining a Configurable Retention Period

Instead of hardcoding the number of days inside our SQL query, we defined a reusable plugin constant.

In flipnzee-auctions.php:

/**
 * Number of days recently closed auctions remain visible.
 */
if ( ! defined( 'FLIPNZEE_AUCTION_HISTORY_DAYS' ) ) {
	define( 'FLIPNZEE_AUCTION_HISTORY_DAYS', 10 );
}

This provides a single location for configuring how long recently completed auctions remain visible.

Changing:

define( 'FLIPNZEE_AUCTION_HISTORY_DAYS', 10 );

to:

define( 'FLIPNZEE_AUCTION_HISTORY_DAYS', 30 );

will automatically extend the history period without modifying any SQL queries.


Updating the Auction Query

The get_active_auctions() method previously returned only active auctions.

It now returns:

  • active auctions
  • recently closed auctions within the configured retention period

The query now resembles:

WHERE
    status = 'active'
    OR (
        status = 'closed'
        AND auction_end >= DATE_SUB(
            NOW(),
            INTERVAL FLIPNZEE_AUCTION_HISTORY_DAYS DAY
        )
    )

Older completed auctions are automatically excluded.


Ordering Results

To improve usability, auctions are now ordered by their ending time.

ORDER BY auction_end DESC

This ensures:

  • Live auctions remain prominent.
  • Recently completed auctions appear directly beneath them.
  • Older retained auctions gradually move lower before disappearing.

Benefits

This small enhancement significantly improves the frontend experience.

Benefits include:

  • Recently completed auctions remain visible.
  • Winning bidders can revisit completed listings.
  • Visitors can verify auction outcomes.
  • The homepage remains uncluttered.
  • No manual cleanup is required.
  • Administrators can easily adjust the retention period.

Example Auction Lifecycle

The auction lifecycle now becomes:

Auction Created
        │
        ▼
Active Auction
        │
        ▼
Auction Ends
        │
        ▼
Recently Closed (Visible for 10 Days)
        │
        ▼
Automatically Removed from Homepage

This creates a much more professional auction experience while preventing old listings from accumulating indefinitely.


Looking Ahead

Keeping recently closed auctions visible is only the first step toward a complete auction history system.

In future lessons, we plan to add:

  • Dedicated Auction Archive page
  • Live / Ending Soon / Closed filters
  • Winner announcement pages
  • Transaction history
  • Escrow payment workflow
  • Website transfer tracking

Together, these features will transform Flipnzee Auctions into a complete marketplace for buying and selling websites and digital assets.

Download Source Code

Download the starting version of the plugin before the lesson:

Download the completed version after this lesson:


Conclusion

In this lesson, we enhanced the Flipnzee Auctions plugin by introducing configurable frontend auction history retention. Instead of removing completed auctions immediately, recently closed auctions remain visible for a configurable period before being automatically removed from the main listing.

This improvement provides greater transparency for buyers, better visibility into completed auctions, and a cleaner long-term marketplace experience while keeping the codebase flexible and easy to maintain.

Leave a Reply

Your email address will not be published. Required fields are marked *