Jump to content

help get $invoices back into ClientAreaPageHome


Recommended Posts

Hi all,

pre WHMCS 8.0, we used to be able to pull all the invoices on clientareahome.tpl but it looks like this is no longer the case, $invoices is not automatically generated on that page anymore. Can someone please help with getting that back with a hook? something like the below for products but for invoices?

PS. code below was taken from the awesome @brian!

<?php

use Illuminate\Database\Capsule\Manager as Capsule;

function products_list_hook($vars) {

   $client = Menu::context('client'); 

   $services = Capsule::table('tblhosting')
               ->join('tblproducts','tblhosting.packageid','=','tblproducts.id')
               ->where('userid',$client->id)
               ->select('tblhosting.*','tblproducts.name as product')
               ->get();

   $encodedata = json_encode($services);
   $decodedata = json_decode($encodedata, true);

   return array("services" => $decodedata);
}
add_hook("ClientAreaPageHome", 1, "products_list_hook");
?>

 

Link to comment
Share on other sites

2 hours ago, unknownsolo said:

pre WHMCS 8.0, we used to be able to pull all the invoices on clientareahome.tpl but it looks like this is no longer the case, $invoices is not automatically generated on that page anymore.

assuming the reason you need the $invoices array is because you have an invoices table on clientareahome, then the quick solution would be..

<?php

# Client Invoices on Homepage Hook
# Written by brian!

function clients_invoices_on_homepage_hook($vars) {

	$invoice = new WHMCS\Invoice();
	$client = Menu::context('client');
	$invoices = $invoice->getInvoices("Unpaid",$client->id,"id","DESC");
	return array("invoices" => $invoices);
}
add_hook("ClientAreaPageHome", 1, "clients_invoices_on_homepage_hook");

there would be alternative ways to create the array, but I think the above method will be the simplest one to give you back what you previously had.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated