Jump to content

Show Product Description on Invoice Item


gtchan

Recommended Posts

Hello All,

 

I would like to add the product description in my invoices. So far our invoices look like this:

 

PRODUCTNAME - Domain (Start Date - End Date)

e.g. Standard - abc.com (04/10/2010 - 03/10/2012)

 

I want to change it to the following:

 

PRODUCTNAME - Domain (Start Date - End Date)

PRODUCT DESCRIPTION

e.g. Shared Hosting - Standard - abc.com (04/10/2010 - 03/10/2012)

Unlimited Disk Space

Unlimited Data Transfer

Unlimited Add on Domain

Unlimited Park Domains

Unlimited Sub Domain

Unlimited Database

 

I can fix it by re-adding the products to include the product description as well but that's not what I would want as a permanent solution. Please let me know if there is some way of adding the product description to the invoice item description.

 

Thanks in advance.

Link to comment
Share on other sites

  • 2 weeks later...

Did you work out a solution for this gtchan?

 

I would like to have the same functionality you've requested, but haven't worked out how to do this at the template level. Is it possible?

 

Additionally, I'd also like to hide configurable options that people haven't ordered/purchased.

 

Eg. Our invoices show a few things such as:

 

Additional Disk Space (GB) : 0x Additional GB $x.xx AUD

 

If the client doesn't purchase these configurables it'd be good to not show them to avoid confusion!

 

 

Any ideas anyone?

 

Cheers

Link to comment
Share on other sites

Did you work out a solution for this gtchan?

 

I would like to have the same functionality you've requested, but haven't worked out how to do this at the template level. Is it possible?

 

Additionally, I'd also like to hide configurable options that people haven't ordered/purchased.

 

Eg. Our invoices show a few things such as:

 

Additional Disk Space (GB) : 0x Additional GB $x.xx AUD

 

If the client doesn't purchase these configurables it'd be good to not show them to avoid confusion!

 

 

Any ideas anyone?

 

Cheers

 

Im still looking for the solution. :roll:

Link to comment
Share on other sites

  • 7 months later...
  • 6 months later...

I have been looking into this issue because I wanted the same functionality. I was hoping that the invoice items that were built into the invoice generation system were just storing a reference number to the product. This is not the case. At the time of the item being saved to an invoice, only the product title is saved as the invoice item description. It does not store any reference to the actual procuct so there is no way to add this info once the invoice is generated.

 

My reason for wanting to do it this way is so I could just edit the custom template for PDF generation. I am never inclined to modify the core code so I have not gone any further with this research. If you were inclined to take this firther you would need to find the PHP file that adds the product items to the "tblinvoiceitems" table and get it to take both the "name" and "description" fields from the "tblproducts" table. Who knows if would cause any other problems though.

 

My suggestion for an enhancement is that there be a config setting that allows you to set the invoice data type per product. You would be able to select from "title" or "title and desctiption".

Link to comment
Share on other sites

  • 1 month later...
  • 3 months later...
  • 1 month later...
Did you work out a solution for this gtchan?

 

I would like to have the same functionality you've requested, but haven't worked out how to do this at the template level. Is it possible?

 

Additionally, I'd also like to hide configurable options that people haven't ordered/purchased.

 

Eg. Our invoices show a few things such as:

 

Additional Disk Space (GB) : 0x Additional GB $x.xx AUD

 

If the client doesn't purchase these configurables it'd be good to not show them to avoid confusion!

 

 

Any ideas anyone?

 

Cheers

 

I'm also interested into the same function-abilities and I ended up on this thread .....

Link to comment
Share on other sites

The requirement to produces invoices with some sort of description other than a simple item line has been requested often.

I am not sure why such a simple thing as adding a field for each product that can be populated with a fuller description is not incorporated.

 

Some time ago (>2 years) I wrote quite a long post on how you could generate full descriptions on the fly using {if} statements .

 

Sadly, that post seems to have gone and I didn't keep a copy :oops:

 

Essentially you added a number of {if} statements that checked the one-line description and inserted additional text depending on the result of that test.

 

If anyone has the old forum files you can find the post in there.

Link to comment
Share on other sites

  • 6 months later...
I have been searching for an answer for this for ages with no simple solution either, if anyone can point in the right direction of who can help that would be fantastic..

sohouk is absolutely spot on about this - in the absence of whmcs adding this feature, then {if} statements are the way to go and do work (tested this afternoon on my own invoicepdf.tpl).

 

I think the simplest solution might be to combine the {if} statements with language overrides - that removes the need to interact with the db and allows the expanded descriptions for products to be stored in an easily editable text file(s) - which can include some formatting features (break returns, lists, underlines, italics etc) within it... and for those using multiple languages on their sites, would allow for the expanded descriptions to be shown in the appropriate language.

 

of course, if you had a *lot* of different products, then it might be worthwhile interacting with the db as the {if} statements would get lengthy, but I suspect for most users there is simply no need to do so.

 

can you give me two examples of your products and the added descriptions you want them to have - hosting products, services, addons whatever... and tell me what the pdf invoice would show for them at the moment.

 

i'm probably not likely to use this feature myself, so it's easier to use some real-world example and write the code accordingly... once you have a working code for three products and their descriptions (2 products and how to treat those without descriptions), then it should be straightforward for anyone to adapt it for 10, 30 or 300 products - well perhaps not 300! :lol:

Link to comment
Share on other sites

Sounds like this is doable via hook and custom code: http://docs.whmcs.com/Hooks:Invoicing#InvoiceCreated. Personally I would think the smarty approach would be flawed when you could hook in before that.

well i've never written a hook in my life, and i'm not going to start now :-P - but "InvoiceCreated" is activated after the email has been sent, so useless in this case - I assume you meant "InvoiceCreationPreEmail".

 

originally, I wasted time yesterday trying to do this in smarty in invoicepdf.tpl, with perfectly good code, and it wasn't working... I then realised that it's not really a smarty template, it's fpdf - so altered the code to pure PHP and it worked fine.

 

which lead to a thought last night, that this method of displaying extended descriptions would also work in viewinvoice.tpl - table layout is slightly different, but principle is the same... just wrap it in {php} and use a slightly modified version of the code.

 

however, you've been around a lot longer than me, so perhaps you are right and hooks would be the correct way to go - I was merely suggesting a template edit that would likely achieve the same result.

Link to comment
Share on other sites

  • 8 months later...

 

I think the simplest solution might be to combine the {if} statements with language overrides - that removes the need to interact with the db and allows the expanded descriptions for products to be stored in an easily editable text file(s) - which can include some formatting features (break returns, lists, underlines, italics etc) within it... and for those using multiple languages on their sites, would allow for the expanded descriptions to be shown in the appropriate language.

 

@brian!: Do you have an example for this solution? I've tried it, but I can not make it in the invoicepdf

Link to comment
Share on other sites

@brian!: Do you have an example for this solution? I've tried it, but I can not make it in the invoicepdf

oh please don't make me revisit my coding from 9 months ago - it'll be embarrassingly poor! :roll:

 

just gone through my notes from Sept on this... here's the relevant part of the quick test code...

 

# Invoice Items
$tblhtml = '<table width="100%" bgcolor="#ccc" cellspacing="1" cellpadding="2" border="0">
   <tr height="30" bgcolor="#efefef" style="font-weight:bold;text-align:center;">
       <td width="80%">'.$_LANG['invoicesdescription'].'</td>
       <td width="20%">'.$_LANG['quotelinetotal'].'</td>
   </tr>';
foreach ($invoiceitems AS $item) {
if (strpos($item['description'],'SSL Certificate') !== false) {
   $tblhtml .= '
   <tr bgcolor="#fff">
       <td align="left">'.nl2br($item['description']).'<br /> fred</td>
       <td align="center">'.$item['amount'].'</td>
   </tr>';}
else
{
   $tblhtml .= '
   <tr bgcolor="#fff">
       <td align="left">'.nl2br($item['description']).'<br /></td>
       <td align="center">'.$item['amount'].'</td>
   </tr>';}

}

so this basic test works by searching the description field for the product name, e.g SSL Cert - if it is found, then it prints "Fred", if it isn't found, it prints nothing.

 

now in practice, you wouldn't print "Fred" - this would be replaced by a relevant Language string... but hopefully you get the idea... you could build a series of {else} statements to cover your product(s) and then leave the "blank" one as the last option.

 

as I say previously, this code was nine months ago and even after a quick glance over it, I can see other alternatives now - but hopefully this will help you achieve what you want to do.

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