DrMTR
DrMTR

Reputation: 509

Show dedicated ip into customer invoice WHMCS

I searched into Stackoverflow for my work that I want to do, and found this thread helpful, but seems that is not working properly.

What do I?

  1. Created a hook into /includes/hooks/ with this code:

    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];
    });
    
  2. Replaced this loop from viewinvoice.tpl file with this one:

    {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}
    

and seems to show Dedicated IP but only for order #4250 in my case. PHPMyAdmin table:

image from phpmyadmin

when check into tblhosting table for that order I see Dedicated IP, and it's showing into invoice:

tblhosting table data

but there is Dedicated IP for many other orders too, but when check that Dedicated IP is not shown for that orders. Where is the issue in this code?

Upvotes: 0

Views: 388

Answers (0)

Related Questions