sslprivateproxy Posted March 5, 2015 Share Posted March 5, 2015 We have clients with the same multiple products/services. When an invoice is generated it contains products/service name but no product service number. Is there anyway to add that product/service id number on the corespondent invoice ? The service id number is also on the link when you go from admin on a client and click on products/services, then you will notice the service id with id=xxxxx on the browser link. The reply i got from whmcs support is : "you might be able to do this using a hook such as http://docs.whmcs.com/Hooks:InvoiceCreationPreEmail This will then allow you to make a database query and grab the service id for the product and then add this to the invoice before it is emailed to the client." Any help is really appreciated 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted March 6, 2015 Share Posted March 6, 2015 it will need some time to be done and tested indeed, and InvoiceCreationPreEmail will help you with the invoice email only, you will need to use action hooks in "view invoice page" and "PDF invoice" too 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 6, 2015 Share Posted March 6, 2015 (edited) as sentq says, you'll need an action hook if you want to include it in your email templates - but you shouldn't need one for the invoicing side of things... e.g in viewinvoice.tpl (the browser invoice), you could just use the following code to show the service ID... {$item.relid} in invoicepdf.tpl (the pdf invoice), you could use... $item['relid'] this works with existing invoices, but I see no reason why it shouldn't also work with new invoices as we're just accessing information already passed to it... i'm sure you'll let me know if it doesn't! it's probably also worth mentioning that relid isn't always a unique number - I think they're unique for their product type (e.g hosting, domain, addon etc), but there could be circumstances where you have an invoice full of different product types that just happen to have the same relid.. it's probably unlikely, but possible. if that's going to become an issue, then perhaps you could tweak the service id to include the product type... e.g if you just use the code below in your viewinvoice template, it will simply show the service ID... {$item.relid} if you wanted to make it more unique, you could add the product type before it... {$item.type}{$item.relid} that would show "Hosting123" where 123 is the service ID, or "Domain123" - you could even abbreviate the product type to 3 letters and show it as UPPERCASE, e.g "HOS123" {$item.type|truncate:3:''|strtoupper}{$item.relid} the possibilities are endless! I should also add that relid will be 0 if it's a custom invoice or a discount - so you might want to consider checking in the code if it is 0, and if so, don't display it. Edited March 6, 2015 by brian! 1 Quote Link to comment Share on other sites More sharing options...
sslprivateproxy Posted March 7, 2015 Author Share Posted March 7, 2015 thank you very much for your solutions, it really helped . 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.