Jump to content

Custom Invoice Number Format


Matt

Recommended Posts

  • WHMCS CEO

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

Link to comment
Share on other sites

  • 3 weeks later...
  • 2 months later...
  • 3 weeks later...

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

Link to comment
Share on other sites

  • 6 months later...
  • 3 months later...

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

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