function tiaop_process_saved_purchases($is_test = false)
{
    // Get the referral information
    if ($is_test) {
        $affiliateId = 1;
    } else {
        $affiliateId = affiliate_wp()->tracking->get_affiliate_id();
    }
    if (empty($affiliateId)) {
        return;
    }
    // Check the database for saved purchases
    $savedPurchase = tiaop_get_saved_purchase();
    if (!$savedPurchase) {
        return;
    }
    // Tell the log that we found a saved purchase and are attempting to process it
    if (WP_DEBUG === true) {
        error_log("tiaop_add_referral: Found a saved purchase; attempting to process it");
        error_log(print_r($savedPurchase, true));
    }
    $amount = $savedPurchase[2];
    $description = $savedPurchase[3];
    $reference = $savedPurchase[4];
    $expiration = $savedPurchase[5];
    // Get the visit id
    if ($is_test) {
        $visitId = 2;
    } else {
        $visitId = affiliate_wp()->tracking->get_visit_id();
    }
    // Call the function that adds the referral
    tiaop_add_referral($affiliateId, $amount, $description, $reference, "", $visitId, $is_test);
    // Log the link
    tiaop_add_history(tiaop_get_user_ip(), $amount, $description, $reference, $expiration, "Visit ID " . $visitId . " linked to Affiliate ID " . $affiliateId, $is_test);
    // Update the conversion stats
    if (!is_test) {
        tiaop_increment_ac($amount);
    }
    // Delete this entry now that it was processed
    tiaop_delete_current_ip();
}
<?php

require_once TIAOP_PLUGIN_DIR . "includes/tiaop_db.php";
$ip_address = tiaop_get_user_ip();
if (isset($_REQUEST["btnSavePurchase"])) {
    $test_results = "IP Address: " . $ip_address;
    $test_results = $test_results . "<br />Database Time: " . tiaop_get_mysql_time();
    $test_results = $test_results . "<br />Creating Saved Purchase.";
    tiaop_save_purchase($ip_address, "1.00", "Test Purchase Description", "Test Purchase Reference", true);
    $test_results = $test_results . "<br />Check Saved Purchase Table.";
}
if (isset($_REQUEST["btnDeletePurchase"])) {
    $test_results = "IP Address: " . $ip_address;
    $test_results = $test_results . "<br />Deleting Saved Purchase.";
    tiaop_delete_current_ip();
    tiaop_purge_history();
    $test_results = $test_results . "<br />Check Saved Purchase Table.";
}
if (isset($_REQUEST["btnProcessPurchase"])) {
    $test_results = "IP Address: " . $ip_address;
    $test_results = $test_results . "<br />Affiliate ID: 1";
    $test_results = $test_results . "<br />Visit ID: 2";
    require_once TIAOP_PLUGIN_DIR . "includes/tiaop_processing.php";
    tiaop_process_saved_purchases(true);
    $test_results = $test_results . "<br />Check History Table.";
}
?>
<div style="margin-top:10px">
	<form method="post" action="">
		<table class="form-table">
			<tr>