izghitu Posted August 26, 2018 Share Posted August 26, 2018 Hi, Is there any way to make WHMCS use letters in invoice numbers as well? For example I need invoices to have numbering like this: US{NUMBER} and also have the number increment automatically. I tried putting the US{NUMBER} thing in the invoice admin area but the letters are being ignored. Please let me know. Thanks 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 27, 2018 Share Posted August 27, 2018 5 hours ago, izghitu said: Is there any way to make WHMCS use letters in invoice numbers as well? from the settings, you could enable sequential invoicing... https://docs.whmcs.com/Invoicing_Setup#Enabling_Sequential_Invoice_Numbering or if you don't need Sequential Numbering, you could use a hook similar to the one I posted in the thread below... <?php /** * Generate Custom Invoice Number Format * @author brian! */ use Illuminate\Database\Capsule\Manager as Capsule; function generate_custom_invoice_number_hook($vars) { $invoiceid = $vars['invoiceid']; $customnumber = "US".$invoiceid; if (isset($customnumber)) { try { $updatedInvoiceNumber = Capsule::table('tblinvoices') ->where('id', $invoiceid) ->update(['invoicenum' => $customnumber,]); } catch (\Exception $e) { // Deal with error } } } add_hook("InvoiceCreationPreEmail",1,"generate_custom_invoice_number_hook"); ?> 0 Quote Link to comment Share on other sites More sharing options...
izghitu Posted August 27, 2018 Author Share Posted August 27, 2018 Magic! Sometimes I wonder how do you know all this stuff. It did the trick but it seems there's an additional problem. Please see attached image, when I view the invoice in the client area it shows the required format in one place but not in the other. Any way to change that to match as well? Please let me know. Thanks 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted August 27, 2018 Share Posted August 27, 2018 The reference number on the right is the ID of the invoice in database (tblinvoices.id). It has nothing in common with invoice number (tblinvoices.invoicenum). Depending on your configuration, both numbers may seem identical, very similar (like in your case) or totally different. If you want to use #US41 as reference number you have to edit bank transfer module and "play" with replace() or create a new one just for this purpose. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 27, 2018 Share Posted August 27, 2018 5 hours ago, izghitu said: Magic! Sometimes I wonder how do you know all this stuff. occasionally, I surprise myself! 💡 5 hours ago, izghitu said: It did the trick but it seems there's an additional problem. Please see attached image, when I view the invoice in the client area it shows the required format in one place but not in the other. Any way to change that to match as well? the simplest solution would be to edit the gateway module code - both the 'banktransfer' and 'mailin' modules have unencrypted code and so can be edited. https://docs.whmcs.com/Bank_Transfer so in /modules/gateways/banktransfer.php (same line of code is in mailin.php too), you can change... $code = '<p>'.nl2br($params['instructions']).'<br />'.$_LANG['invoicerefnum'].': '.$params['invoiceid'].'</p>'; to... $code = '<p>'.nl2br($params['instructions']).'<br />'.$_LANG['invoicerefnum'].': '.$params['invoicenum'].'</p>'; ... and that should now make both invoices numbers match. if you're using the WHMCS auto-updater, you may need to manually edit the banktransfer.php file after each update, but as you can see, it's only a trivial change to make. the documentation does correctly state that another option is to duplicate the file, and then edit that duplicate file - but then you'd have to reassign clients using 'banktransfer' to use the modified 'banktransfer2' instead - but whether that's worth the hassle, depends on the number of clients to change... personally i'd just edit banktransfer.php and leave them using it. 1 Quote Link to comment Share on other sites More sharing options...
izghitu Posted August 27, 2018 Author Share Posted August 27, 2018 That helped. Thanks very much for your valuable suggestions! 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.