Hello,
I don't get any further.
How can i access the nested order data by key?
I've tried it also with the json. I only get the first 4 values like: success101
Regards
<?php
use WHMCS\Database\Capsule;
add_hook('AcceptOrder', 1, function($vars)
{
// Get current order id.
$orderID = $vars['orderid'];
$command = 'GetOrders';
$postData = array(
'id' => $orderID,
);
$adminUsername = 'xxx'; // Optional for WHMCS 7.2 and later
$results = localAPI($command, $postData, $adminUsername);
$filename = "/WHMCS_TEST/Testfile.txt";
$f = fopen($filename, 'wb');
if (!$f) {
die('Error creating the file ' . $filename);
}
//INFO - JSON Structure: GetOrders - WHMCS Developer Documentation
$json = json_encode(array('data' => $results));
foreach($results as $result)
{
fputs($f, $result);
foreach($result as $orders)
{
fputs($f, $orders);
foreach($orders as $order)
{
$test = $order;
fputs($f, $test);
}
}
}
fclose($f);
});