How to disable invoice generation for 0.00 invoices

The short answer is we cannot disable.

Some time ago I was looking for solution to NOT send (or even generate maybe) invoices with total 0.00
It is a bit weird for clients to see payment confirmation about their $0.00 invoices. They are kinda “free” invoices and they are marked paid instantly.
So far I didnt find any solution and found a lot of similar requests on official forum thread.

So here’s a hook to disable email sendings for such invoices:

function disable_00_invoices($vars) {
   $email_template_name = $vars['messagename']; # Email template name being sent
   $relid = $vars['relid']; # Related ID it's being sent for - client ID, invoice ID, etc...
   //Checking for certain template name, if so - this is our case
   if ($email_template_name == "Invoice Created" || $email_template_name == "Invoice Payment Confirmation")
       //getting total of the invoice
       $result = select_query('tblinvoices', 'total', array("id" => $relid));
       $data = mysql_fetch_assoc($result);
       //if it is equal to '0.00' we disable email sending
       if (isset($data['total']) && $data['total'] == '0.00')
       $merge_fields['abortsend'] = true;

   return $merge_fields;

Little about me:

Im professional web developer. Love to work with PHP-driven projects. WHMCS seems to me the way to share my knowledges. Some of you may be interested in hiring me - drop me a line or take a look at my Odesk profile

6 Comments + Add Comment

  • […] = true; } } return $merge_fields; } add_hook("EmailPreSend",1,"desabilita_fatura");FonteSe preferir, fa├ža o download: Desabilita faturas sem valor (0)Basta descompactar na raiz do seu […]

  • This is great! Thank you. Where do I put this code to make it work?

  • Thanks for posting this. This should’ve been included with WHMCS.

  • Hi
    does this work in new version of whmcs?

  • Hi there.!
    Look what I need is for one of my products are not charged in the WHMCS invoice that does not lead me to that product

Leave a comment