1

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?

Harikrishnan
  • 9,688
  • 11
  • 84
  • 127

2 Answers2

2

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.

nathanr
  • 150
  • 1
  • 9
2

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/

sMyles
  • 2,418
  • 1
  • 30
  • 44