Jump to content

Client doesn't want to receive any invoices


El Morgan

Recommended Posts

Hi - 

I have a client who has asked not to receive any invoices.  They just want to be charged.  I've looked, but am not finding a place where I can turn off that kind of email for them.  I considered using an email address that goes to nowhere, but then they will also not get ticket notifications.

Is it possible to turn off just the invoice notifications?  BTW,  nothing is checked next to Email Notifications under the Contact tab in their customer record.

Thanks!

EM

Link to comment
Share on other sites

19 hours ago, El Morgan said:

Is it possible to turn off just the invoice notifications?

not for just one client... you could disable those email templates, but that would affect all clients.

there is an old free action hook that can disable invoices being emailed to specific clients (invoices are generated but not sent)...

http://whmscripts.net/whmcs/2011/disabling-invoice-creation-emails-in-whmcs-on-a-per-client-basis/

it's still working in v7.2.3 (and I assume later), but it will have to be updated at some point as it's still using mysql_query... that will be relatively straightforward, but I suspect this will continue to work as is until at least v8 (so for some time yet!) :idea:

the download link in the above page isn't working, so i'll post the code below...

<?php
/*
 * disable_invoice_notification.php
 * Version 1.0 
 * 
 * An action hook for WHMCS that allows you to disable sending of invoice
 * creation notifications for selected clients.
 *
 * To install, just set the $client_ids and (optionally) $logfile variables
 * then place this script in your whmcs/includes/hooks/ directory.
 * 
 * Tested with WHMCS 4.5.2
 * 
 * Reed Murphy <reed@whitedoggreenfrog.com> 2010
 * 
 * For more free cPanel / WHM / WHMCS scripts, check out http://whmscripts.net/
 */

function hook_disable_invoice_notification($vars) {
    // If $logfile is not blank, messages about emails not sent will be
    // logged to this file.
    // $logfile = "/home/whmcs/presendemail.log";
    // $logfile = "";
    $logfile = "";

    // An array of IDs of clients that should not receive invoice notification
    // emails. Replace these with your own.
    $client_ids = Array(
        "3"
    );

    // The names of the email templates that you don't want sent.
    $message_names = Array(
        "Credit Card Invoice Created",
        "Invoice Created",
        "Invoice Payment Reminder"
    );

    $merge_fields = array();
    if (in_array($vars['messagename'], $message_names)) {
        $invoice_id = mysql_real_escape_string($vars['relid']);
        $query =
            "SELECT `userid`, CONCAT_WS(' ', `firstname`, `lastname`) as 'name' ".
            "FROM `tblinvoices` ".
            "JOIN `tblclients` ON `tblinvoices`.`userid` = `tblclients`.`id` ".
            "WHERE `tblinvoices`.`id` = '" . $invoice_id ."'";
        $r = full_query($query);
        if ($r) {
            $row = mysql_fetch_row($r);
            $client_id = $row[0];
            $client_name = $row[1];
            if (in_array($client_id, $client_ids)) {
                $merge_fields['abortsend'] = true; // don't send email

                if ($logfile) {
                    $pid = getmypid();
                    $logline = sprintf(
                        "%s pre_send_email[%d]: ".
                        "Not sending email '%s' to client %s\n",
                        date("Y-m-d H:i:s"),
                        $pid,
                        $vars['messagename'],
                        $client_name
                    );
                    $fh = fopen($logfile, "a");
                    fwrite($fh, $logline);
                    fclose($fh);
                }
            }
        }
    }

    return $merge_fields;
}

add_hook("EmailPreSend", 10, "hook_disable_invoice_notification");

you should just need to edit the line below and use the ID of the client that you want this to work for.

    $client_ids = Array(
        "3"
    );

 

Link to comment
Share on other sites

  • 2 years later...

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