Hi stack i have one issue that dont know how to resolve. I want to show Dedicated IP from customer order to show like this:
I make a short check, and found
Create php file in whmcs_dir/includes/hooks/
(say: dedicated_ip.php) and add the following code:
<?php
use WHMCS\Database\Capsule as DB;
add_hook('ClientAreaPageViewInvoice', 1, function($vars) {
$dedicatedIps = [];
foreach ($vars['invoiceitems'] as $k => $item) {
$ip = '';
if ($item['type'] == 'Hosting') {
$hosting = DB::table('tblhosting')->select('dedicatedip')->where('id', $item['relid'])->first();
if (!is_null($hosting)) {
$ip = $hosting->dedicatedip;
}
}
$dedicatedIps[$k] = $ip;
}
return ['dedicatedIps' => $dedicatedIps];
});
This code will run only in the invoice view page, and adds an array of dedicated IPs for each invoice items. Domains for example will have empty ip.
Then in viewinvoice.tpl update the invoice items loop as following:
{foreach from=$invoiceitems item=item key=key}
<tr>
<td>
{$item.description}{if $item.taxed eq "true"} *{/if}
{if $key|in_array:$dedicatedIps}
<br>IP: {$dedicatedIps[$key]}
{/if}
</td>
<td class="text-center">{$item.amount}</td>
</tr>
{/foreach}