<?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>
function tiaop_save_purchase($payerIpAddress, $amount, $description, $reference, $is_test = false) { global $wpdb; $db_table_name = $wpdb->prefix . "opafti_saved_purchases"; // Set expiration settings_fields("tiaop-settings"); $expiration_value = esc_attr(get_option("tiaop_expiration_value", "1")); $expiration_units = esc_attr(get_option("tiaop_expiration_units", "days")); $currentDt = new DateTime(tiaop_get_mysql_time()); $expires = date_add($currentDt, date_interval_create_from_date_string($expiration_value . " " . $expiration_units)); $expires = $expires->format("Y\\-m\\-d\\ h:i:s"); // Log history tiaop_add_history($payerIpAddress, $amount, $description, $reference, $expires, "Saved", $is_test); // Save the purchase info tiaop_delete_ip($payerIpAddress); $wpdb->insert($db_table_name, array("ip_address" => $payerIpAddress, "amount" => $amount, "description" => $description, "reference" => $reference, "expires" => $expires)); // Increment Affiliate Saved //if(!$is_test) tiaop_increment_as(); }