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; } add_hook("EmailPreSend",1,"disable_00_invoices");
[…] = 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?
this is file for hooks directory: /includes/hooks/
read more about hooks here: http://docs.whmcs.com/Hooks
Thanks for posting this. This should’ve been included with WHMCS.
Hi
does this work in new version of whmcs?
Thanks
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