WHMCS CEO Matt Posted January 21, 2010 WHMCS CEO Share Posted January 21, 2010 WHMCS already has the ability to assign a custom invoice number format to paid invoices using the "Sequential Paid Invoice Numbering" feature under General Settings > Invoicing (primarily used for Proforma invoicing). However, some users have asked about how they can assign a custom invoice number format as soon as an invoice generates. We'll here's how: 1. Begin by creating a file in the /includes/hooks/ folder called custominvoicenumberformat.php 2. Add the following code to the file: <?php function hook_custominvoicenumberformat($vars) { $invoiceid = $vars['invoiceid']; $customnumber = date("Y")."-".$invoiceid; update_query("tblinvoices",array("invoicenum"=>$customnumber),array("id"=>$invoiceid)); } add_hook("InvoiceCreationPreEmail",1,"hook_custominvoicenumberformat"); ?> 3. In this example the invoice number is set to the current year as a prefix, folled by the ID number. You can customise the $customnumber line to your desired format. And it's as simple as that. From that point forward, any invoices generated by the cron will be assigned your custom invoice number format. Hope that helps! Matt 0 Quote Link to comment Share on other sites More sharing options...
Grzesiu Posted February 10, 2010 Share Posted February 10, 2010 Warning: Cannot modify header information 0 Quote Link to comment Share on other sites More sharing options...
rider Posted May 6, 2010 Share Posted May 6, 2010 Hi, Just tried this but I got white page with most WHMCS page in client area & also admin area. If I delete this file, all work again. i did twice try, same issue Regards 0 Quote Link to comment Share on other sites More sharing options...
webio Posted May 22, 2010 Share Posted May 22, 2010 Hello, I've changed a little invoice numbering to invoiceid/year. Now when customer is downloading his invoice it gets filename only for a year (2010.pdf). Where I can change it to something like invoicenumber-2010.pdf? Is there a way to start numbering invoices every year from the beggining? Thanks 0 Quote Link to comment Share on other sites More sharing options...
striddy Posted May 22, 2010 Share Posted May 22, 2010 1. Setup > General Settings > Invoices > Invoice Starting # 2. No 0 Quote Link to comment Share on other sites More sharing options...
ZeroGravity Posted December 15, 2010 Share Posted December 15, 2010 So does this only work via cron? Is it possible to use a hook to set a custom invoice number when manually creating an invoice through the admin panel? I setup everything as described above but the invoice number is not set when creating an invoice in the admin panel. 0 Quote Link to comment Share on other sites More sharing options...
meldominguez Posted March 26, 2011 Share Posted March 26, 2011 I have created the custominvoicenumberformat.php file and the pdf invoices haven't changed yet. They only show the invoice number, but not the date or anything else. I have created new invoices, paid them, etc and the pdf file doesn't change. How is this supposed to work, or when is it supposed to work? Thank you 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.