Jump to content

How to add product/service id number on the invoice


Recommended Posts

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

Link to comment
Share on other sites

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 by brian!
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