- Replace
REPLACE_ME
with a username of your admin (API) account. - Upload the content below inside of
../includes/hooks/AutoAcceptOrders.php
Note: I did not make this original script, the original was published under MIT licence on a seperate repo but was later deleted.
<?php
function AutoAcceptOrders_accept($vars)
{
$command = 'GetInvoice';
$postData = array(
'invoiceid' => $vars['invoiceid'],
);
$adminUsername = 'REPLACE_ME'; //put here your admin user
$ispaid = true;
if ($vars['invoiceid'])
{
$resultinvoice = localAPI($command, $postData, $adminUsername);
$ispaid = ($resultinvoice['result'] == 'success' && $resultinvoice['balance'] <= 0) ? true : false;
}
$command = 'AcceptOrder';
$postData = array(
'orderid' => $vars['orderId'],
'autosetup' => true,
'sendemail' => true,
);
if ((true && $ispaid))
{
$result = localAPI($command, $postData, $adminUsername);
print_r($results);
logActivity("Order Accept", 0);
if (is_array($result))
{
foreach ($result as $index => $value)
{
logActivity("$index:$value", 1);
}
}
}
}
add_hook("OrderPaid", 1, "AutoAcceptOrders_accept");
?>