How to get product group details in WHMCS invoice template file invoicepdf.tpl?

1.4k Views Asked by At

I am customising WHMCS invoice template using invoicepdf.tpl. It is a PHP script basically arrange data in HTML format and convert it to PDF. I can only see client info and invoice details in that file. How can I take product group details there?

2

There are 2 best solutions below

0
nathanr On BEST ANSWER

You have to use a whmcs invoice hook( https://developers.whmcs.com/hooks-reference/invoices-and-quotes/ ). For example:

Then in the hook you can request the data you want from tblproductgroups or any other table if needed.

0
sMyles On

This should do what you're looking for:

add_hook("InvoiceCreationPreEmail", 1, "invoice_productgroup");

function invoice_productgroup($vars)
{
   $result = full_query("SELECT id, description, (SELECT (SELECT (SELECT tblproductgroups.name FROM tblproductgroups WHERE id = tblproducts.gid) FROM tblproducts WHERE id = tblhosting.packageid) FROM tblhosting WHERE id = tblinvoiceitems.relid) AS groupname FROM tblinvoiceitems WHERE invoiceid='".$vars['invoiceid']."' AND type='Hosting';");

   while($data = mysql_fetch_array ($result))
       if($data['groupname'] !== NULL)
           update_query("tblinvoiceitems", array("description" => $data['groupname']." - ".$data['description']), array("id" => $data['id']));
}

https://whmcs.community/topic/126837-product-group-in-invoice-item-description/