Feature Requests
Share ideas, discuss and vote on requests from other users in community
 

Remove addons displayed on Invoice when not purchased

VCCS Telecom shared this idea 5 years ago
Under Consideration

Currently add-ons are shown on every invoice for the product associated even if they are not purchased. Agreed they should be available as an upgrade on the back-end but with many options the invoice is cluttered with confusing garbage.

Comments (9)

photo
2

I agree, no need to show items not ordered on the invoice!

photo
1

photo
2

I still REALLY think this should be built in, but I have created some code we can add to fix it.

**Tested Working on our system, but use at your own risk**

invoice.tpl (Starting on Line 92 for us, within the foreach loop)

  1. {php}

    $text = preg_replace("/\:\s0\sx\s/","+",$this->_tpl_vars['invoiceitem']['description']);

    $text = preg_replace("/.*\+/","+",$text);

    $text = preg_replace("/\+.*/","",$text);

    $this->_tpl_vars['invoiceitem']['description'] = $text;

    {/php}

invoicepdf.tpl (Replace this whole foreach loop)

  1. foreach ($invoiceitems AS $item) {

    //These 3 lines remove 0 Quantity items, and the 4th line set the new string to the running variable

    $text = preg_replace("/\:\s0\sx\s/","+",$item['description']);

    $text = preg_replace("/.*\+/","+",$text);

    $text = preg_replace("/\+.*(\n?)/","",$text);

    $item['description'] = $text;

    $rowcount = $pdf->getNumLines($item['description'], 140);

    $pdf->MultiCell(140,$rowcount * 5,$item['description'],1,'L',0,0);

    $pdf->MultiCell(40,$rowcount * 5,$item['amount'],1,'C',0,0);

    $pdf->Ln();

    }

You're Welcome : )

-Stephen

photo
1

Hi, have you manage to get this running in 7.6.1?

photo
photo
1

Not sure if the templates have changed since you posted this, but here is what I used of your modified code to make it work:

In viewinvoice.tpl

  1. {php}
  2. global $text, $newdescription;
  3. $this_invoice_item = $this->get_template_vars('item');
  4. $this_item_description = $this_invoice_item['description'];
  5. $text = preg_replace("/\:\s0\sx\s/","+",$this_item_description);
  6. $text = preg_replace("/.*\+/","+",$text);
  7. $text = preg_replace("/\+.*/","",$text);
  8. $this->assign('newdescription',$text);
  9. {/php}


and in invoicepdf.tpl

  1. foreach ($invoiceitems AS $item) {
  2. $text = preg_replace("/\:\s0\sx\s/","+",$item['description']);
  3. $text = preg_replace("/.*\+/","+",$text);
  4. $text = preg_replace("/\+.*(\n?)/","",$text);
  5. $tblhtml .= '
  6. <tr bgcolor="#fff">
  7. <td align="left">'.nl2br($text).'<br /></td>
  8. <td align="center">'.$item['amount'].'</td>
  9. </tr>';
  10. }

These seemed to work for me on the default when I had issues just pasting your code in there. But your code got me 95% of the way there and now I know some smarty and more php.

photo
1

How I do leave Quantity in place?

photo
1

this really needs to be fixed!

photo
1

Is there any way this can be implemented in the confirmation email? I was able to use the code above succesfully to filter the client area and the PDF but no love on the email body.

Placeholder is {$invoice_html_contents}

Can a similar regex be implemented in the email body?

photo
1

This is needed, Many clients get frustrated to see all options they don't buy on the invoice.

It looks cheap and unprofessional.

I tried the fixes above on WHMCS 7.6.1 but it looks like it's not working any more.