Lesson 65: Adding Transaction Status Management to Flipnzee Auctions


What You’ll Learn

In this lesson, you’ll enhance the Transactions page by allowing administrators to change the status of auction transactions directly from the WordPress dashboard.

By the end of this lesson, you’ll be able to:

  • Display transaction status as a clickable action
  • Add row actions to each transaction
  • Update transaction status securely
  • Use WordPress nonces for protection
  • Process admin actions with custom handlers
  • Record status changes in the activity log

Why This Matters

Currently every transaction is stored like this:

IDStatus
1pending
2pending

Once payment is received or the website/domain has been transferred, an administrator needs a way to mark the transaction as:

  • Pending
  • Paid
  • Completed
  • Cancelled
  • Refunded (future lesson)

Without this capability, the transaction system is read-only.


What We’ll Build

We’ll transform this:

Status
pending

into something like:

Status
Pending

[Mark Paid]

Later:

Status
Paid

[Mark Completed]

Finally:

Status
Completed

Files We’ll Modify

  • admin/class-admin-transactions.php
  • includes/class-transaction-manager.php
  • includes/class-activity-log.php
  • flipnzee-auctions.php

Features We’ll Implement

Step 1

Create transaction status update method.


Step 2

Add admin action handler.


Step 3

Verify WordPress nonce.


Step 4

Update transaction status in database.


Step 5

Write activity log entry.


Step 6

Display success notice.


Step 7

Add “Mark Paid” row action.


Step 8

Add “Mark Completed” row action.


Step 9

Hide actions once transaction is completed.


Step 10

Test the complete workflow.


Expected Result

Instead of only viewing transactions, administrators will be able to manage their progress:

Transaction #5

Status: Pending

Actions:
✓ Mark Paid

↓

Status: Paid

Actions:
✓ Mark Completed

↓

Status: Completed

Skills You’ll Learn

  • WordPress admin action handlers
  • Secure nonce verification
  • Updating custom database tables
  • Admin notices
  • Row actions in WP_List_Table
  • Activity logging
  • Transaction workflow design

End Result

After Lesson 65, the Flipnzee Auctions plugin will evolve from simply recording transactions to managing the full transaction lifecycle. Administrators will be able to move transactions through meaningful stages—such as Pending, Paid, and Completed—while every status change is securely processed and automatically recorded in the activity log. This creates a practical workflow for handling completed auctions and prepares the plugin for future enhancements like payment gateway integration, downloadable invoices, email notifications, refunds, and commission tracking.

Lesson 64 Implementation: Creating the Transactions Admin Page in Flipnzee Auctions

After completing automatic transaction generation in Lesson 63, the next step was to allow administrators to view all completed auction transactions directly from the WordPress dashboard.

In this lesson, we created a dedicated Transactions admin page that displays every transaction stored in the plugin’s custom database table. This gives administrators a centralized place to monitor completed sales and lays the groundwork for future payment processing, invoices, commissions, refunds, and reporting.


What We Built

By the end of this lesson, the plugin includes:

  • A new Transactions submenu
  • A custom admin page
  • A WP_List_Table based transactions table
  • Automatic loading of transaction records
  • Display of important transaction information
  • Professional WordPress admin interface

Step 1 — Create the Transactions Table Class

Inside the admin folder create:

admin/class-admin-transactions.php

This file is responsible for:

  • Loading the transactions page
  • Creating the transactions table
  • Displaying all stored transactions

Step 2 — Create the Transactions List Table

Inside the same file create a class extending WP_List_Table.

Example:

class Flipnzee_Transactions_Table extends WP_List_Table {

}

This gives us the familiar WordPress admin table interface.


Step 3 — Define Table Columns

Create the columns method.

public function get_columns() {

    return array(
        'id'          => 'ID',
        'auction_id'  => 'Auction',
        'listing_id'  => 'Listing',
        'seller_id'   => 'Seller',
        'buyer_id'    => 'Buyer',
        'winning_bid' => 'Winning Bid',
        'status'      => 'Status',
        'created_at'  => 'Created',
    );
}

These columns match the structure of the custom transactions database table.


Step 4 — Load Transactions From Database

Inside prepare_items() we queried the database.

global $wpdb;

$table = $wpdb->prefix . 'flipnzee_transactions';

$this->items = $wpdb->get_results(
    "SELECT * FROM {$table} ORDER BY id DESC",
    ARRAY_A
);

The newest transactions now appear first.


Step 5 — Configure Table Headers

Still inside prepare_items() we configured the table headers.

$this->_column_headers = array(
    $columns,
    array(),
    array(),
    'id',
);

This tells WordPress which columns should appear.


Step 6 — Display Column Values

Next we created the default column renderer.

public function column_default( $item, $column_name ) {

    return isset( $item[ $column_name ] )
        ? esc_html( $item[ $column_name ] )
        : '';
}

This automatically outputs the correct value for each column.


Step 7 — Register the Transactions Menu

Inside class-admin.php we added another submenu.

add_submenu_page(
    'flipnzee-auctions',
    'Transactions',
    'Transactions',
    'manage_options',
    'flipnzee-transactions',
    array( $this, 'transactions_page' )
);

The new menu now appears beneath Flipnzee Auctions.


Step 8 — Create the Page Callback

The callback loads and displays the table.

Example:

$table = new Flipnzee_Transactions_Table();

$table->prepare_items();

$table->display();

This is all that’s required for WordPress to render the table.


Step 9 — Load the New Admin File

Inside the main plugin file we loaded the new class.

require_once FLIPNZEE_AUCTION_PATH .
    'admin/class-admin-transactions.php';

Without this step the Transactions page would never load.


Step 10 — Test the Feature

After activating the updated plugin we verified everything worked correctly.

The Transactions page displayed:

  • Transaction ID
  • Auction ID
  • Listing ID
  • Seller
  • Buyer
  • Winning Bid
  • Status
  • Created Date

Every automatically generated transaction appeared successfully.


Result

The Flipnzee Auctions plugin now provides a dedicated Transactions dashboard for administrators.

When an auction ends and a winner is determined, the plugin now has the ability to:

  • Store the transaction
  • Display it inside WordPress
  • Allow administrators to monitor completed sales

This transforms the plugin from simply tracking auctions into managing the entire auction lifecycle.


What We Learned

In this lesson we learned how to:

  • Create a custom WordPress admin page
  • Use WP_List_Table
  • Display custom database records
  • Load transaction history
  • Register new admin submenu pages
  • Build a professional backend interface

Challenges Faced

During implementation we encountered a few issues that are common when building WordPress admin tables:

  • A misplaced method inside prepare_items() caused PHP syntax errors, which were resolved by moving get_table_classes() outside the method while keeping it inside the class.
  • Initially, the Transactions menu did not appear because the new admin file had not been included in the main plugin file.
  • After everything worked, an extra header row appeared at the bottom of the table. This is a cosmetic behavior of the simplified WP_List_Table implementation and does not affect functionality. It will be refined in a future lesson when we enhance sorting, pagination, and table styling.

Working through these issues reinforced the importance of careful class structure, proper file loading, and incremental testing during plugin development.

Download Source Code

Download the starting version of the plugin before the lesson:

Download the completed version after this lesson:


Final Outcome

By the end of Lesson 64, Flipnzee Auctions includes a fully functional Transactions management page that lists all automatically generated auction transactions. This provides administrators with immediate visibility into completed sales and establishes the foundation for future features such as payment integration, invoices, commissions, refunds, transaction status updates, and downloadable reports.

Lesson 64: Build a Transaction Management Dashboard in WordPress Admin


Objective

Create a dedicated Transactions page in the WordPress admin where administrators can monitor every completed auction transaction.

This will become the operational dashboard before adding escrow integration.


What We Will Build

A new admin menu:

Flipnzee Auctions
├── Auctions
├── Add Auction
├── Activity Log
├── Transactions   ← NEW

The page will display something like:

IDAuctionListingSellerBuyerWinning BidStatusCreated
131491RajeevRajeev$55,555,609PendingToday

Why This Lesson Matters

Right now:

  • Auctions close automatically ✅
  • Winner is determined ✅
  • Transaction is created ✅

But administrators cannot actually see or manage transactions.

A transaction dashboard is the natural bridge before adding:

  • Escrow integration
  • Payment processing
  • Buyer/Seller confirmation
  • Domain transfer workflow
  • Status updates

Files We’ll Modify

New

admin/class-transactions-table.php

A WordPress list table for transactions.


New

admin/class-admin-transactions.php

Renders the Transactions page.


Modify

admin/class-admin.php

Register the new submenu.


Reuse

includes/class-transaction-manager.php

Read transaction data from the database.


Features

1. Transactions Table

Display:

  • Transaction ID
  • Auction ID
  • Listing ID
  • Seller
  • Buyer
  • Winning Bid
  • Status
  • Created Date

2. Pagination

Support large numbers of transactions.


3. Search

Search by:

  • Auction ID
  • Listing ID
  • Buyer
  • Seller

4. Status Filter

Dropdown:

All
Pending
Escrow
Completed
Cancelled
Refunded

5. Sorting

Allow sorting by:

  • Date
  • Winning Bid
  • Status

6. Future Ready

We’ll design the table so adding action buttons later is easy:

View
Mark Escrow Received
Mark Completed
Cancel

Those buttons won’t do anything yet—they’ll be implemented in later lessons.


What We’ll Learn

During this lesson you’ll practice:

  • Creating another WP_List_Table
  • Reading custom database tables
  • Pagination
  • Searching
  • Sorting
  • Filtering
  • Secure admin pages
  • Preparing for escrow workflows

Expected Result

The admin will have a professional Transactions dashboard similar to WordPress Posts or Users.

Example:

-------------------------------------------------------------
 Transactions

 ID   Auction  Buyer      Seller     Winning Bid     Status
-------------------------------------------------------------
 1      31     Rajeev     Rajeev      $55,555,609    Pending
 2      32     Alice      Bob         $7,500         Completed
 3      33     John       Mary        $2,300         Escrow
-------------------------------------------------------------

Why This Is the Right Next Step

This lesson doesn’t just add another admin screen—it creates the control center for everything that happens after an auction ends. Once this dashboard exists, integrating an escrow provider becomes much simpler because every transaction will have a visible lifecycle (Pending → Escrow → Completed).

After Lesson 64, we’ll be in an excellent position to begin the escrow integration itself, keeping your focus on making Flipnzee.com ready to host real auctions.

Lesson 63 Implementation: Building an Event-Driven Transaction System for Flipnzee Auctions

After completing the database structure in Lesson 62, the next logical step was to automate what happens after an auction successfully ends.

Instead of tightly coupling transaction creation with the auction closing logic, this lesson introduced an event-driven architecture using WordPress hooks. This approach keeps the plugin modular and makes future integrations—such as escrow services, payment gateways, and notifications—much easier.


Objective

Automatically create a transaction record whenever an auction winner is determined.

By the end of this lesson:

  • Auction winner determination triggers an event.
  • The Transaction Manager listens for that event.
  • A transaction is automatically created.
  • The Activity Log records the transaction creation.

Step 1: Fire an Event After Determining the Winner

Winner determination is handled inside:

includes/class-bid-manager.php

After recording the winner in the Activity Log, add:

do_action(
	'flipnzee_auction_winner_determined',
	$auction_id,
	$winner
);

The end of the method becomes:

Flipnzee_Activity_Log::log(
	'winner_determined',
	$auction_id,
	$winner->bidder_id,
	sprintf(
		'Winning bid: %s',
		$winner->bid_amount
	)
);

do_action(
	'flipnzee_auction_winner_determined',
	$auction_id,
	$winner
);

return true;

This broadcasts an event without knowing who will respond to it.


Step 2: Create the Transaction Manager Listener

Open:

includes/class-transaction-manager.php

Add a constructor:

public function __construct() {

	add_action(
		'flipnzee_auction_winner_determined',
		array(
			$this,
			'create_transaction_from_auction',
		),
		10,
		2
	);
}

Whenever the event is fired, this callback will execute automatically.


Step 3: Build the Callback Method

Add the following method:

/**
 * Create transaction when an auction winner is determined.
 *
 * @param int    $auction_id Auction ID.
 * @param object $winner     Winning bid.
 * @return void
 */
public function create_transaction_from_auction(
	$auction_id,
	$winner
) {

	global $wpdb;

	$auction = $wpdb->get_row(
		$wpdb->prepare(
			"SELECT *
			FROM {$wpdb->prefix}flipnzee_auctions
			WHERE id = %d",
			$auction_id
		)
	);

	if ( ! $auction ) {
		return;
	}

	$listing_author = (int) get_post_field(
		'post_author',
		$auction->listing_id
	);

	$transaction_id = self::create_transaction(
		array(
			'auction_id'  => $auction->id,
			'listing_id'  => $auction->listing_id,
			'seller_id'   => $listing_author,
			'buyer_id'    => $winner->bidder_id,
			'winning_bid' => $winner->bid_amount,
		)
	);

	if ( $transaction_id ) {

		Flipnzee_Activity_Log::log(
			'transaction_created',
			$auction->id,
			$winner->bidder_id,
			'Transaction ID: ' . $transaction_id
		);
	}
}

This method:

  • retrieves the auction,
  • identifies the seller,
  • creates a transaction,
  • logs the successful creation.

Step 4: Load the Transaction Manager

Open:

flipnzee-auctions.php

Near the bottom:

new Flipnzee_Shortcodes();

Add:

new Flipnzee_Transaction_Manager();

Result:

new Flipnzee_Shortcodes();
new Flipnzee_Transaction_Manager();

Without instantiating the class, WordPress would never register the action hook.


Step 5: Verify Syntax

Run:

php -l includes/class-bid-manager.php

Then:

php -l includes/class-transaction-manager.php

Both should report:

No syntax errors detected

Step 6: Test the Workflow

Create a test auction.

Place at least one bid.

Allow the auction to expire naturally.

After scheduled maintenance runs, verify:

Activity Log

You should see:

  • winner_determined
  • transaction_created

Transactions Table

A new row should appear inside:

wp_flipnzee_transactions

Example:

AuctionSellerBuyerStatus
3122pending

Event Flow

The plugin now follows this architecture:

Auction Ends
        │
        ▼
Bid Manager
Determines Winner
        │
        ▼
do_action(
    flipnzee_auction_winner_determined
)
        │
        ▼
Transaction Manager
        │
        ▼
Creates Transaction
        │
        ▼
Activity Log

Each component has a single responsibility.


Challenges Faced

During implementation, an important architectural refinement emerged.

Initially, the event hook was placed inside the Auction Manager. However, testing showed that winner determination actually occurs within the Bid Manager. Moving the hook to the correct location ensured that the event is fired exactly when the winning bid is known.

This adjustment resulted in a cleaner and more maintainable design.


Lessons Learned

Several important WordPress development concepts were reinforced:

  • WordPress hooks can be used to build event-driven systems.
  • Managers should communicate through actions rather than direct method calls.
  • Keeping responsibilities separated improves maintainability.
  • Activity logs provide valuable insight during debugging and verification.
  • Incremental testing after each change makes it easier to isolate and resolve issues.

Download Source Code

Download the starting version of the plugin before the lesson:

Download the completed version after this lesson:


Outcome

By the end of this lesson, the Flipnzee Auctions plugin automatically creates a transaction record whenever an auction successfully determines a winner. The transaction is stored in its own database table and recorded in the Activity Log, providing a reliable foundation for future features such as escrow integration, payment processing, seller confirmation, buyer confirmation, and ownership transfer.

This lesson marks an important architectural milestone, transitioning the plugin toward a scalable, event-driven design that will support the remaining stages of the auction lifecycle.

Lesson 63: Automatically Create Transactions When an Auction Ends Using WordPress Action Hooks

Overview

In the previous lesson, we built the Transaction Manager and created the wp_flipnzee_transactions table. However, transactions are still created manually. The next logical step is to connect the Auction Manager with the Transaction Manager.

Rather than calling the Transaction Manager directly from the Auction Manager, we’ll use one of WordPress’ most powerful features—Action Hooks. This creates a loosely coupled, event-driven architecture where different components communicate through events instead of depending on each other directly.

By the end of this lesson, whenever an auction winner is determined, the plugin will automatically create a pending transaction without modifying the core auction logic.


What You Will Learn

In this lesson you will learn how to:

  • Understand event-driven programming in WordPress.
  • Create a custom WordPress action hook.
  • Pass auction data through an action hook.
  • Listen for custom actions.
  • Automatically create transactions after an auction closes.
  • Reduce coupling between plugin components.
  • Build an extensible architecture for future escrow integrations.

Why This Improvement Matters

Suppose the Auction Manager directly inserts a transaction into the database.

Today that may seem fine.

Tomorrow you may also want to:

  • Send buyer emails.
  • Send seller emails.
  • Start escrow.
  • Notify administrators.
  • Trigger webhooks.
  • Generate invoices.
  • Award badges.
  • Push data to an external CRM.

If every feature is added inside the Auction Manager, the class quickly becomes difficult to maintain.

Using WordPress hooks solves this problem elegantly.

Instead of saying:

“Create a transaction.”

the Auction Manager simply says:

“An auction has ended.”

Any other class can decide whether it wants to respond.


Architecture Before Lesson 63

Auction Manager
      │
      ▼
Determine Winner

Architecture After Lesson 63

Auction Manager
      │
      ▼
do_action()

      │
      ▼

Transaction Manager

      │
      ▼

Create Transaction

Later we can attach even more listeners:

Auction Manager

      │

do_action()

      │
      ├────────► Transaction Manager
      ├────────► Email Manager
      ├────────► Escrow Manager
      ├────────► Notification Manager
      └────────► REST API

This is exactly how many mature WordPress plugins are designed.


What Will Be Implemented

During this lesson we will:

Step 1

Fire a custom action when a winner is determined.


Step 2

Create a listener inside the Transaction Manager.


Step 3

Automatically insert a new transaction.


Step 4

Log transaction creation in the Activity Log.


Step 5

Test the complete workflow.


Expected Result

Before Lesson 63:

Auction Ends

↓

Winner Selected

↓

Nothing Else Happens

After Lesson 63:

Auction Ends

↓

Winner Selected

↓

WordPress Action Fired

↓

Transaction Created

↓

Activity Logged

Files That Will Be Modified

  • includes/class-auction-manager.php
  • includes/class-transaction-manager.php
  • includes/class-activity-log.php

No database changes are required.


Skills You’ll Practice

  • WordPress Action Hooks
  • Custom Events
  • Loose Coupling
  • Event-Driven Programming
  • Clean Plugin Architecture
  • Object-Oriented WordPress Development

Difficulty Level

Intermediate

This lesson introduces one of the most important architectural concepts in WordPress development. Understanding custom action hooks will help you build plugins that are easier to extend, maintain, and integrate with future features such as escrow services, payment gateways, and notification systems.


Final Thoughts

Lesson 63 represents a significant shift in the design of the Flipnzee Auctions plugin. Instead of tightly connecting the Auction Manager with every future component, we will use WordPress’ hook system to broadcast auction events and allow independent classes to respond as needed.

This event-driven approach provides a solid foundation for the remaining roadmap, including escrow integration, payment workflows, buyer and seller notifications, and third-party integrations, while keeping the codebase clean and modular.

Implementing Lesson 62: Building the Transaction Manager Foundation in Flipnzee Auctions

As the Flipnzee Auctions plugin continues to evolve into a complete online auction marketplace, it becomes increasingly important to organize the code into well-defined components. After completing automatic winner determination in the previous lesson, the next step was to introduce a dedicated Transaction Manager.

Instead of embedding transaction logic directly inside the Auction Manager, this lesson focuses on building the architectural foundation that will eventually support escrow integration, payment processing, ownership transfer, and transaction history.

In this implementation, no visible changes are introduced to the plugin interface. However, significant backend improvements prepare the plugin for future marketplace features.


Why a Transaction Manager?

When an auction ends successfully, several business processes may follow:

  • Creating an escrow transaction
  • Recording payment information
  • Sending buyer and seller notifications
  • Tracking ownership transfer
  • Marking the transaction as completed

Rather than placing all of these responsibilities inside the Auction Manager, it is better to create a dedicated class responsible only for transactions.

This follows the Single Responsibility Principle (SRP) and makes the plugin easier to maintain and extend.


Step 1: Create the Transactions Database Table

The first task was extending the database installer to create a new table.

File modified:

includes/class-database.php

A new table was added:

wp_flipnzee_transactions

using dbDelta().

/*
 * Create transactions table.
 */
$transaction_table = $wpdb->prefix . 'flipnzee_transactions';

$sql = "CREATE TABLE {$transaction_table} (

	id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,

	auction_id BIGINT UNSIGNED NOT NULL,

	listing_id BIGINT UNSIGNED NOT NULL,

	seller_id BIGINT UNSIGNED NOT NULL,

	buyer_id BIGINT UNSIGNED NOT NULL,

	winning_bid DECIMAL(12,2) NOT NULL,

	status VARCHAR(30) DEFAULT 'pending',

	created_at DATETIME DEFAULT CURRENT_TIMESTAMP,

	updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,

	PRIMARY KEY (id),

	KEY auction_id (auction_id),

	KEY buyer_id (buyer_id),

	KEY seller_id (seller_id),

	KEY status (status)

) {$charset_collate};";

dbDelta( $sql );

After reactivating the plugin, the new database table appeared successfully in phpMyAdmin.


Step 2: Create the Transaction Manager

A brand-new class was introduced.

New file:

includes/class-transaction-manager.php

Initial class structure:

<?php
/**
 * Transaction Manager.
 *
 * @package Flipnzee_Auctions
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class Flipnzee_Transaction_Manager {

}

This dedicated class will manage all transaction-related functionality in future lessons.


Step 3: Load the New Class

The main plugin loader was updated to include the new class.

File modified:

flipnzee-auctions.php

Code added:

require_once FLIPNZEE_AUCTION_PATH .
	'includes/class-transaction-manager.php';

This ensures the Transaction Manager is available throughout the plugin.


Step 4: Create Transactions Programmatically

The first functional method was added.

/**
 * Create a transaction.
 *
 * @param array $data Transaction data.
 * @return int|false
 */
public static function create_transaction( $data ) {

	global $wpdb;

	$table = $wpdb->prefix . 'flipnzee_transactions';

	$result = $wpdb->insert(
		$table,
		array(
			'auction_id'  => $data['auction_id'],
			'listing_id'  => $data['listing_id'],
			'seller_id'   => $data['seller_id'],
			'buyer_id'    => $data['buyer_id'],
			'winning_bid' => $data['winning_bid'],
			'status'      => 'pending',
		),
		array(
			'%d',
			'%d',
			'%d',
			'%d',
			'%f',
			'%s',
		)
	);

	if ( false === $result ) {
		return false;
	}

	return $wpdb->insert_id;
}

Although not yet connected to auction completion, this method provides the core functionality for creating marketplace transactions.


Step 5: Retrieve a Transaction

A second method was implemented for retrieving transaction details.

/**
 * Get a transaction.
 *
 * @param int $transaction_id Transaction ID.
 * @return object|null
 */
public static function get_transaction( $transaction_id ) {

	global $wpdb;

	$table = $wpdb->prefix . 'flipnzee_transactions';

	return $wpdb->get_row(
		$wpdb->prepare(
			"SELECT * FROM {$table} WHERE id = %d",
			$transaction_id
		)
	);
}

Keeping database queries inside the Transaction Manager avoids repeating SQL throughout the plugin.


Step 6: Update Transaction Status

Finally, a method was added for updating transaction status.

/**
 * Update transaction status.
 *
 * @param int    $transaction_id Transaction ID.
 * @param string $status         New status.
 * @return bool
 */
public static function update_status(
	$transaction_id,
	$status
) {

	global $wpdb;

	$table = $wpdb->prefix . 'flipnzee_transactions';

	$result = $wpdb->update(
		$table,
		array(
			'status' => sanitize_text_field( $status ),
		),
		array(
			'id' => absint( $transaction_id ),
		),
		array(
			'%s',
		),
		array(
			'%d',
		)
	);

	return false !== $result;
}

This method will later allow the plugin to move transactions through stages such as:

  • Pending
  • Escrow Started
  • Payment Received
  • Ownership Transferred
  • Completed
  • Cancelled

Testing the Implementation

After completing the changes:

  • The plugin activated successfully.
  • No PHP syntax errors were reported.
  • The wp_flipnzee_transactions table was successfully created.
  • The new Transaction Manager loaded correctly.
  • Existing auction functionality remained unaffected.

This confirmed that the new architecture had been integrated without breaking existing features.

Download Source Code

Download the starting version of the plugin before the lesson:

Download the completed version after this lesson:


Lessons Learned

This lesson demonstrates an important software engineering principle:

Build the architecture before building the features.

Although users cannot yet create or view transactions, introducing a dedicated Transaction Manager now will make future development much cleaner.

Future features such as escrow integration, payment gateways, notifications, and transaction history can all be implemented within this class without increasing the complexity of the Auction Manager.


Final Thoughts

Lesson 62 marks an important milestone in the Flipnzee Auctions project. Rather than focusing on user-facing functionality, this lesson strengthens the plugin’s internal architecture by introducing a dedicated Transaction Manager and transaction database table.

As the plugin grows into a full-featured auction marketplace, this modular design will make future enhancements significantly easier to implement, maintain, and extend.

In the next lesson, we will connect the Auction Manager and the Transaction Manager using WordPress action hooks so that a transaction is created automatically whenever an auction winner is determined. This event-driven approach will further improve the plugin’s flexibility and maintainability.

Lesson 62: Building the Transaction Manager Foundation for Flipnzee Auctions

With automatic winner determination now complete, the Flipnzee Auctions plugin has reached an important milestone. Every completed auction now has a confirmed winner and a final bid amount.

The next logical step is not to integrate directly with an escrow service. Instead, we first need to build a solid transaction management layer that will act as the bridge between completed auctions and future payment or escrow workflows.

In this lesson, we will create the Transaction Manager Foundation, providing the architecture that will support escrow providers, payment gateways, notifications, and transaction tracking in future lessons.


Why Not Integrate Escrow Immediately?

When developing marketplace software, it is tempting to connect directly to an escrow provider as soon as a winner has been selected.

However, this creates tight coupling between auction logic and payment processing.

Instead, professional marketplace platforms introduce a separate transaction layer.

The workflow becomes:

Auction
      ↓
Winner Determined
      ↓
Transaction Created
      ↓
Escrow
      ↓
Ownership Transfer
      ↓
Transaction Completed

This separation makes the system easier to maintain, extend, and test.


Why Introduce a Transaction Manager?

The Auction Manager should remain responsible only for auction-related operations such as:

  • creating auctions,
  • activating auctions,
  • closing auctions,
  • determining winners.

It should not become responsible for:

  • escrow,
  • payment processing,
  • notifications,
  • transaction history.

Those responsibilities belong to a dedicated Transaction Manager.

Following the Single Responsibility Principle (SRP) keeps each class focused on one area of responsibility.


What We Will Build

During this lesson we will create a brand-new class:

includes/class-transaction-manager.php

This class will become responsible for managing every transaction that occurs after an auction has completed.

Initially, it will provide methods such as:

  • Create Transaction
  • Retrieve Transaction
  • Update Transaction Status

Additional capabilities will be added in later lessons.


Creating a Transactions Table

To support transaction management, a new database table will be introduced:

wp_flipnzee_transactions

Each completed auction will eventually create a corresponding transaction record.

The table is designed to store information such as:

  • Transaction ID
  • Auction ID
  • Listing ID
  • Seller ID
  • Buyer ID
  • Winning Bid
  • Transaction Status
  • Creation Date
  • Last Updated Date

Having a dedicated table keeps transaction information separate from auction data while allowing both systems to remain connected.


Benefits of a Separate Transaction Layer

This design offers several important advantages.

Clean Architecture

Each manager class performs one job.

Auction Manager manages auctions.

Bid Manager manages bids.

Transaction Manager manages transactions.

Future managers can handle:

  • Escrow
  • Notifications
  • Payments
  • Emails

without modifying the auction engine.


Easier Escrow Integration

Whether Flipnzee eventually integrates with:

  • Escrow.com,
  • another escrow provider,
  • manual escrow,
  • or an in-house payment system,

all of them can simply interact with the Transaction Manager rather than modifying auction logic.


Improved Maintainability

As new features are added, developers will know exactly where transaction-related code belongs.

Instead of one extremely large manager class, the plugin grows through focused, modular components.


Preparing for Future Lessons

This architectural foundation prepares the plugin for several major features.

Upcoming lessons will build on the Transaction Manager by adding:

  • Automatic transaction creation
  • Winner notifications
  • Seller notifications
  • Transaction status updates
  • Escrow integration
  • Payment tracking
  • Ownership transfer workflow

Each feature will plug into the Transaction Manager without requiring major changes to the existing auction system.


What You’ll Learn

In this lesson, you will learn how to:

  • Design a scalable WordPress plugin architecture.
  • Apply the Single Responsibility Principle.
  • Create a dedicated database table for transactions.
  • Build a reusable Transaction Manager.
  • Prepare a plugin for future integrations.
  • Separate business logic into modular components.

Why the Roadmap Was Revised

Originally, the plan was to create transactions directly inside the Auction Manager.

During implementation, it became clear that this would gradually turn the Auction Manager into a very large class responsible for multiple unrelated tasks.

The architecture was therefore improved before the feature was completed.

Instead of tightly coupling auctions with transactions, the project now introduces a dedicated Transaction Manager that communicates with the rest of the plugin through well-defined methods and WordPress actions.

This approach closely follows the modular architecture used throughout WordPress itself.


Final Thoughts

As software projects grow, architecture becomes just as important as functionality.

Introducing a Transaction Manager may not produce an immediately visible feature for users, but it establishes a clean, scalable foundation that will support every post-auction process in the future.

By investing in a well-structured architecture now, the Flipnzee Auctions plugin is better prepared for secure escrow integration, transaction tracking, and the complete marketplace workflow that will power Flipnzee.com.


Next Lesson

In Lesson 63, we will connect the Auction Manager and the Transaction Manager using WordPress action hooks, allowing transactions to be created automatically whenever a winner is determined—without tightly coupling the two classes.

Lesson 61 Implementation: Automatically Determine the Winning Bidder When an Auction Ends

One of the most important milestones in the Flipnzee Auctions project has now been completed. In this lesson, the plugin was enhanced to automatically determine the winning bidder as soon as an auction expires.

Previously, the plugin was already capable of automatically closing expired auctions. However, after the auction was closed, no winner was selected automatically. An administrator would have needed to determine the highest bidder manually.

This lesson bridges that gap and moves the project much closer to becoming a fully functional online auction marketplace.


Objective

The goal of this lesson was to:

  • Detect the highest valid bid after an auction closes.
  • Save the winning bidder in the auction record.
  • Update the final bid amount.
  • Record the event in the Flipnzee Activity Log.
  • Lay the foundation for future escrow integration.

The Problem

The plugin already contained logic that automatically changed an auction’s status from Active to Closed after the auction end time.

However, closing an auction alone is not sufficient.

A complete auction workflow should also:

  • Find the highest bidder.
  • Declare the winner.
  • Store the winner permanently.
  • Prepare the transaction for the next stage.

Without this step, the marketplace cannot proceed to payment or escrow.


Implementation Overview

The implementation consisted of three major improvements.

1. Creating a Winner Selection Method

A new method named determine_winner() was added to the Bid Manager.

Its responsibility is to:

  • Retrieve all bids for an auction.
  • Sort bids by highest amount.
  • Use the earliest bid as the tie-breaker.
  • Save the winning bidder.
  • Update the final bid.
  • Record the event in the activity log.

This centralizes the winner selection logic so it can be reused in future features.


2. Updating the Auction Closing Process

The auction closing routine was modified to perform two operations:

  1. Automatically close expired auctions.
  2. Immediately determine the winner for every auction that was closed.

Before updating auction statuses, the IDs of all expired auctions are collected.

Once the status update completes successfully, the plugin loops through those auction IDs and calls the new winner selection method.

This keeps the code clean while ensuring every expired auction receives a winner automatically.


3. Recording the Winner

After selecting the winning bid, the plugin stores:

  • Winning User ID
  • Final Bid Amount

inside the auction record.

It also records a new activity log entry similar to:

winner_determined
Auction: 31
User: 2
Winning bid: 55555609.00

This creates an audit trail that administrators can review at any time.


Testing the Feature

After uploading the updated plugin:

  • The plugin activated successfully.
  • An auction automatically changed to Closed after expiration.
  • The highest bidder was identified correctly.
  • The winner was saved.
  • A new winner_determined entry appeared in the Activity Log.

This confirmed that the entire workflow executed successfully.


Challenges Faced

During development, one major issue occurred.

The plugin failed to activate because of a PHP parse error caused by an incorrectly placed closing brace inside the admin class.

Using:

php -l admin/class-admin.php

made it possible to quickly identify the syntax issue.

After correcting the misplaced brace and re-uploading the plugin, activation succeeded.

This served as another reminder of the importance of validating PHP files before deployment.


Files Modified

The following files were updated during this lesson:

  • includes/class-bid-manager.php
  • includes/class-auction-manager.php

No database schema changes were required because the necessary fields already existed.


What Was Achieved

By the end of this lesson, the Flipnzee Auctions plugin can now:

  • Automatically close expired auctions.
  • Identify the highest bidder.
  • Resolve ties using the earliest bid.
  • Save the winner in the auction record.
  • Update the final bid amount.
  • Record the event in the Activity Log.

These enhancements significantly improve the automation of the auction lifecycle.


Lessons Learned

Several important development practices were reinforced:

  • Separate business logic into reusable methods.
  • Keep auction closing and winner determination as distinct responsibilities.
  • Always validate PHP files using php -l before deployment.
  • Activity logging is invaluable when testing automated workflows.

Download Source Code

Download the starting version of the plugin before the lesson:

Download the completed version after this lesson:


Looking Ahead

With automatic winner determination now complete, the next stage of development will focus on transforming a completed auction into a real transaction.

Upcoming lessons will introduce:

  • Buyer and seller notifications.
  • Transaction records.
  • Escrow workflow preparation.
  • Payment integration.
  • Marketplace completion.

The project has now moved beyond simply displaying auctions. It is steadily evolving into a complete auction marketplace capable of supporting secure, end-to-end online transactions.

Lesson 61: Automatically Determine the Winning Bidder When an Auction Ends

One of the most important milestones in the Flipnzee Auctions plugin is moving from simply accepting bids to automatically determining the winner once an auction expires.

Until now, the plugin has allowed visitors to place bids, displayed the highest bidder, tracked activity, and automatically closed expired auctions. However, once an auction ended, there was no definitive step that officially declared a winner.

In this lesson, we will build the logic that identifies the highest valid bidder and records them as the auction winner.


Why This Feature Matters

An auction is only complete when a winner has been determined.

Without this feature:

  • administrators must manually inspect bid history,
  • mistakes can occur,
  • notifications cannot be automated,
  • escrow cannot begin,
  • ownership transfer cannot proceed.

Automatically determining the winner removes manual work while increasing trust in the auction platform.


What We Will Build

By the end of this lesson, the plugin will:

  • detect when an auction closes,
  • retrieve all valid bids,
  • determine the highest bidder,
  • resolve ties fairly,
  • save the winning bidder,
  • save the winning bid amount,
  • prepare the auction for the escrow workflow.

Planned Database Changes

The auction record will be enhanced with dedicated winner information.

Examples include:

  • Winner User ID
  • Winning Bid
  • Winning Time
  • Auction Result Status

This allows the plugin to remember the winning bidder even after additional administrative actions are taken.


Winner Selection Rules

The plugin should follow a clear and transparent process.

For example:

  1. Auction expires.
  2. Retrieve all bids.
  3. Ignore invalid bids.
  4. Sort by highest bid.
  5. If multiple bids have the same amount, choose the earliest one.
  6. Store the winner.
  7. Mark the auction as completed.

This ensures every auction follows the same rules.


Preparing for Escrow Integration

Determining the winner is the foundation for the next major milestone.

Once a winner exists, the plugin can automatically:

  • notify the buyer,
  • notify the seller,
  • initiate an escrow transaction,
  • display payment instructions,
  • begin ownership transfer.

Without a confirmed winner, none of these workflows can begin.


Administrator Benefits

Instead of manually checking bid history, administrators will immediately know:

  • who won,
  • the winning amount,
  • when the winning bid was placed,
  • whether the auction completed successfully.

This reduces administration time and minimizes disputes.


Future Enhancements

The winner information introduced in this lesson will later support features such as:

  • Winner email notifications
  • Seller notifications
  • Escrow integration
  • Transaction tracking
  • Buyer dashboard
  • Seller dashboard
  • Completed auction history
  • Marketplace reputation system

What You’ll Learn

In this lesson, you will learn how to:

  • query auction bids efficiently,
  • determine the highest valid bid,
  • handle tie-breaking rules,
  • update auction records,
  • prepare auctions for post-auction workflows,
  • design software that supports future business processes.

Final Thoughts

Automatically determining the winning bidder marks the transition from a bidding system to a complete auction platform. It establishes a trusted and repeatable process for ending auctions fairly and creates the foundation for escrow, notifications, and secure ownership transfer.

In Lesson 62, we will build the Auction Completion Workflow, automatically transitioning completed auctions into the next stage of the transaction lifecycle.

Lesson 60: Parsing Activity Logs into a Professional Admin Table in the Flipnzee Auctions Plugin

As the Flipnzee Auctions plugin continued to evolve, the Activity Log introduced in previous lessons became increasingly useful for tracking important auction events. However, displaying each log entry as a single line made it difficult to scan and understand.

In this lesson, the plugin was enhanced to parse each log entry and display it inside a structured WordPress admin table. This small improvement greatly increases readability and lays the groundwork for advanced features like searching, filtering, exporting, and pagination.


Why Improve the Activity Log?

A plain text log might work for developers, but administrators need information that is easy to understand at a glance.

Instead of displaying this:

[2026-07-05 19:19:14] Event: auction_auto_closed | Auction: 0 | User: 0 | Details: 1 auction(s) automatically closed.

the Activity Log now presents the information in separate columns.

Date & TimeEventAuctionUserDetails
2026-07-05 19:19:14auction_auto_closed001 auction(s) automatically closed.

This makes the history of auction activity much easier to browse.


What Was Implemented

During this lesson, the Activity Log renderer was upgraded to:

  • Read each log entry from the log file
  • Parse the stored text using a regular expression
  • Extract individual values
  • Display the information inside a structured HTML table
  • Continue displaying unknown log formats safely using a fallback

Understanding the Log Format

Every activity recorded by the plugin follows a consistent structure.

Example:

[2026-07-05 19:19:14] Event: auction_auto_closed | Auction: 0 | User: 0 | Details: 1 auction(s) automatically closed.

The parser separates this into five individual fields:

  • Date & Time
  • Event
  • Auction ID
  • User ID
  • Details

Because every log entry follows the same format, PHP can reliably extract the values before displaying them.


Using Regular Expressions

The parser uses PHP’s preg_match() function to identify each section of the log.

Rather than treating the entire line as plain text, it captures the different values individually.

This allows each value to be displayed inside its own table cell.


Creating the Admin Table

Instead of printing one long string, the renderer now creates a table containing:

  • Date & Time
  • Event
  • Auction
  • User
  • Details

Each log entry becomes a separate row.

The result is much cleaner and far easier to read.


Fallback for Unexpected Entries

Not every log file remains perfectly formatted forever.

To prevent errors, the renderer checks whether the regular expression successfully matches the expected format.

If it does, the values are displayed in separate columns.

If not, the original log line is still displayed safely inside a single table row.

This ensures older or unexpected entries never disappear.


Testing the Feature

After updating the plugin:

  1. Upload the latest plugin ZIP.
  2. Activate the plugin.
  3. Open:

Flipnzee Auctions → Activity Log

If log entries already exist, they should automatically appear as structured table rows.


Final Result

The Activity Log is now significantly more useful for administrators.

Instead of reading long text strings, administrators can quickly identify:

  • when something happened,
  • what event occurred,
  • which auction was involved,
  • which user performed the action,
  • and additional details.

This makes troubleshooting and auditing much easier.


What I Learned

This lesson demonstrated how small user interface improvements can dramatically improve usability.

Key concepts covered included:

  • Reading log files
  • Parsing structured text
  • Using PHP regular expressions
  • Displaying dynamic data inside HTML tables
  • Building fallback logic for unexpected input
  • Improving the WordPress admin experience

Download Source Code

Download the starting version of the plugin before the lesson:

Download the completed version after this lesson:


Looking Ahead

With structured activity logs now working, the next logical improvements include:

  • Search within logs
  • Filter events by type
  • Download logs as CSV
  • Pagination for large log files
  • Clear log button
  • Colour-coded event badges
  • Date range filtering

These enhancements will transform the Activity Log into a powerful administration and debugging tool for the Flipnzee Auctions plugin.


Lesson 60 Complete! The Flipnzee Auctions plugin now features a professional, structured Activity Log that presents auction events in an organized table, making plugin administration cleaner, faster, and more user-friendly.