Jump to content

Remove 0 Quantity Option Lines From Invoices


Recommended Posts

Since WHM wont add it as a feature, here is the code to do it yourself...

 

Code uses a couple Regex searches to remove the offending lines and leave your invoices squeaky clean.

 

viewinvoice.tpl

(Replace the Foreach loop)

{foreach key=num item=invoiceitem from=$invoiceitems}
{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}

<tr bgcolor=#ffffff><td id="invoiceitemsrow" style="border:1px solid #cccccc;border-bottom:0px;">{$invoiceitem.description}{if $invoiceitem.taxed eq "true"} *{/if}</td><td align="center" id="invoiceitemsrow" style="border:1px solid #cccccc;border-bottom:0px;border-left:0px;">{$invoiceitem.amount}</td></tr>

{/foreach}

 

 

invoicePDF.tpl

(Replace the Foreach loop)

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();
}

 

 

Removes 0 quantity configurable addon lines from invoices so your customers don't think they are being billed for stuff they didn't sign up for.

 

Enjoy,

-Stephen

Link to comment
Share on other sites

Hello Stephenitsg,

 

Thanks for providing this workaround. I moved your thread to the User Contributions subforum as it seemed to be more appropriate. Also, if you would like to see this added to WHMCS and you haven't already submitted a feature request, please do so using the link in my signature.

 

As always folks, any user submitted work around is appreciated but it has not been tested and therefore is not supported by WHMCS. Please use at your discretion.

 

--Thanks

Link to comment
Share on other sites

  • 4 years later...

For the latest version of WHMCS, I have re-written some of the code in viewinvoice.tpl to still keep working in 7.6.x+. I hope this continues to help people who hate the 0 x configurable items on the invoices.

{foreach from=$invoiceitems item=item}
        {$text = preg_replace("/\:\s0\sx\s/","+",$item.description)}
        {$text = preg_replace("/.*\+/","+",$text)}
        {$text = preg_replace("/\+.*/","",$text)}
        {$item.description = $text}
        <tr>
          <td>{$text}{if $item.taxed eq "true"} *{/if}</td>
          <td class="text-center">{$item.amount}</td>
       </tr>
{/foreach}

 

Phil Ciccone

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.

×
×
  • 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