ManagedCloud-Hosting Posted November 24, 2020 Share Posted November 24, 2020 Few of my clients have objected to receiving unpaid pdf invoices via email, but majority of them want to receive the invoices... Clients who have objected have mentioned that we should send them only paid invoices via email but at the same time they require the invoice payment reminders and other invoice related emails but without the attachment. How to achieve this ? Thanks 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted November 24, 2020 Share Posted November 24, 2020 They can object whatever they want but you make decisions. Not them. That being said, I highly recommend to keep using proforma invoicing because a proforma: Has no fiscal value Doesn't follow particular rules, sequential numbering or dates It can be cancelled, edited and ignored Let's say a customer has 10 overdue proforma for 10 hosting accounts he no longer wants to renew. He ignores reminders, days go by and there's nothing more to say. Now let's see what happens if you turn off proforma invoicing. Every document issued by WHMCS is a real invoice with fiscal value. It must be recorded by your accountant not matter its status. Paid or Unpaid makes no difference. Now multiply this scenario for 100 customers and you have 1000 Unpaid invoices that your accountant must record. Cons? It costs money & time. Pro? None. That being said, I understand that big companies may require you to issue unpaid invoices but they are an exception. You could issue Unpaid invoices manually just for them. There are third-party modules that make this process easier but that's not a big deal. 0 Quote Link to comment Share on other sites More sharing options...
ManagedCloud-Hosting Posted November 25, 2020 Author Share Posted November 25, 2020 Hi @Kian Yes using Proforma is the perfect solution and we are using it as we have to issue GST Invoices. So issuing a Proforma Invoice and then after receiving payment and adding the payment converts it to Tax Invoice for clients. This is the reason I wanted to know how to send only email reminders (without pdf invoice) to certain clients while the rest of our clients continue to receive invoices along with the reminder emails. 11 hours ago, Kian said: I understand that big companies may require you to issue unpaid invoices but they are an exception. As we issue proforma invoice and it's emailed with the reminder mails few companies have requested us to only send the reminder emails (without pdf invoice) as it has details for proforma invoice number / invoice date / due date and invoice amount. So they can book the invoice details with the inputs from the email itself and once they make the payment then we should send them the Tax Invoice (Final Invoice). But at the same time there are clients who want to receive the reminder emails as well as pdf invoice as attachment. 11 hours ago, Kian said: I highly recommend to keep using proforma invoicing because a proforma Absolutely It's a nightmare for accountants and waste of time and efforts at our end. I don't understand why people who don't want to pay just let the company know that they want to leave the service rather than getting terminated and bringing in a bad name for themselves or their company. Yes i agree 100% with you that Proforma Invoicing is the best way to deal with such issues. 11 hours ago, Kian said: Let's say a customer has 10 overdue proforma for 10 hosting accounts he no longer wants to renew. He ignores reminders, days go by and there's nothing more to say. Now let's see what happens if you turn off proforma invoicing. Every document issued by WHMCS is a real invoice with fiscal value. It must be recorded by your accountant not matter its status. Paid or Unpaid makes no difference. Now multiply this scenario for 100 customers and you have 1000 Unpaid invoices that your accountant must record. Cons? It costs money & time. Pro? None. How to achieve this ? can this be done using client groups ? Thanks 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted November 25, 2020 Share Posted November 25, 2020 (edited) What about: Leave proforma invoicing enabled Disable the sending of "Invoice created" email template (the one with PDF attachments) to a specific customers / groups Could it work? Edited November 25, 2020 by Kian 0 Quote Link to comment Share on other sites More sharing options...
ManagedCloud-Hosting Posted November 25, 2020 Author Share Posted November 25, 2020 @Kian Thanks for your rely How to do this ? Need to check once with staging WHMCS before updating with production... 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted November 25, 2020 Share Posted November 25, 2020 This script should work. 0 Quote Link to comment Share on other sites More sharing options...
ManagedCloud-Hosting Posted November 25, 2020 Author Share Posted November 25, 2020 So if an automated reminder is sent out then also it will not send the invoice to certain client group as attachment using this hook ? Thanks 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted November 25, 2020 Share Posted November 25, 2020 Yes. Basically the hook aborts the sending of "Invoice Created" email templates to customers assigned to say group ID #3. If you don't want to use groups, you can specify an array user IDs. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 25, 2020 Share Posted November 25, 2020 21 hours ago, VirtualWorldGlobal said: Clients who have objected have mentioned that we should send them only paid invoices via email but at the same time they require the invoice payment reminders and other invoice related emails but without the attachment. I think even with the hook, everyone would still receive email invoice payment reminders *with* the PDF invoice attachments. 0 Quote Link to comment Share on other sites More sharing options...
ManagedCloud-Hosting Posted November 25, 2020 Author Share Posted November 25, 2020 I think as you and kian are experts I should remain silent 😷 Yes your understanding is right, This was my question, I need to stop sending pdf invoice for specific client in invoice created / Invoice reminders / etc... emails... This client (group / id's) want to receive only the final Tax Invoice (pdf invoice via email) once we add their payment and it gets converted to Tax Invoice 50 minutes ago, VirtualWorldGlobal said: So if an automated reminder is sent out then also it will not send the invoice to certain client group as attachment using this hook ? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 25, 2020 Share Posted November 25, 2020 4 minutes ago, VirtualWorldGlobal said: I think as you and kian are experts I should remain silent 😷 oh on invoicing in WHMCS, I always defer to Kian - he's spent his life examining the topic in greater detail than I ever will. 8 minutes ago, VirtualWorldGlobal said: Yes your understanding is right, This was my question, I need to stop sending pdf invoice for specific client in invoice created / Invoice reminders / etc... emails... if PDF invoices are enabled, then I don't think you can selectively disable them per client/group etc. I can remember Kian submitting a FR about removing pdf attachments from emails, but it's got less than a handful of votes (one of them was me and I assume Kian was another!)... so don't expect that feature to be added any time soon. possibly I can think of one workaround (untried, it might work but I don't know how much work would be involved to do it), but i'd be inclined to agree with Kian and unless these clients are kicking up an absolute stink about it and threatening to walk, to just keep sending the attachments as now. 0 Quote Link to comment Share on other sites More sharing options...
ManagedCloud-Hosting Posted November 25, 2020 Author Share Posted November 25, 2020 We are continuing to do this for almost a year now already, you can understand our situation :) 21 minutes ago, brian! said: possibly I can think of one workaround (untried, it might work but I don't know how much work would be involved to do it), but i'd be inclined to agree with Kian and unless these clients are kicking up an absolute stink about it and threatening to walk, to just keep sending the attachments as now. 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted November 25, 2020 Share Posted November 25, 2020 (edited) 1 hour ago, brian! said: I think even with the hook, everyone would still receive email invoice payment reminders *with* the PDF invoice attachments. 1 hour ago, brian! said: I can remember Kian submitting a FR about removing pdf attachments from emails, but it's got less than a handful of votes (one of them was me and I assume Kian was another!)... so don't expect that feature to be added any time soon. Both things are true but long time ago I managed to find a boring way to overcome this problem. The hook I previously posted, prevents WHMCS from sending the email with the PDF invoice attachment. The next step is to re-send such email "manually" by directly using phpMailer included in WHMCS. Require /vendor/phpmailer/phpmailer/PHPMailerAutoload.php new PHPMailer() Load WHMCS settings (company name, email, mailtype, smtp host / user / pass / port / ssl) If SMTP is in use, decrypt SMTP Password and ->IsSMTP() otherwise ->IsMail() Select from tblemailtemplates the Email Template based on customer's language Retreive all the necessary data from tblinvoices and tblinvoiceitems and str_replace() all {$smarty_variables} in email body & title ->Send(); Basically we prevent WHMCS from sending the email but soon after we re-send it "manually" as we want. That being said, please wait. Few hours ago I realized probably that there's an easier way... I'm testing it... if it works I want to punch myself in the face. Edited November 25, 2020 by Kian 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 25, 2020 Share Posted November 25, 2020 12 minutes ago, Kian said: Basically we prevent WHMCS from sending the email but soon after we re-send it "manually" as we want. That being said, please wait. Few hours ago I realized probably that there's an easier way... I'm testing it... if it works I want to punch myself in the face. the two thoughts I had are whether you could use PES to change the email template choice.type on the fly,... and more viable to just prevent sending the invoice emails for these clients, and then resend a non-invoice type template via API (thus avoiding attachments)... though you'd have to fill the mergefields and other fields accordingly. 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted November 27, 2020 Share Posted November 27, 2020 (edited) I've just finsihed adding the second part. It works for me. Here is the updated version of the script. There's a new parameter ($removePDFAttachments). Set true if just want to remove PDF invoice attachments for the selected users. In this case the hook stops WHMCS from sending the email and re-send it without attachment. Let me know if it works @VirtualWorldGlobal On 11/25/2020 at 7:15 PM, brian! said: the two thoughts I had are whether you could use PES to change the email template choice.type on the fly,... and more viable to just prevent sending the invoice emails for these clients, and then resend a non-invoice type template via API (thus avoiding attachments)... though you'd have to fill the mergefields and other fields accordingly. Wait, what is PES? 😟 I bet it's not Pro Evolution Soccer. Edited November 27, 2020 by Kian 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 27, 2020 Share Posted November 27, 2020 9 minutes ago, Kian said: I bet it's not Pro Evolution Soccer. it is - i'm working on an addon module that converts the WHMCS staff into a PES team.... unfortunately, they have a habit of scoring own goals; passing it along the back four to play for time; ignoring comments from the paying crowd; group hugs for successfully completing a two-yard pass... and the manager has lost his voice. ⚽ it was a typo - I meant EPS (EmailPreSend). btw - I think it would be useful if the comments of your hooks at least list which releases it was tested on / written for... obviously, some are v8 only, but that might not necessarily be obvious to everyone downloading. 1 Quote Link to comment Share on other sites More sharing options...
Kian Posted November 27, 2020 Share Posted November 27, 2020 7 hours ago, brian! said: it is - i'm working on an addon module that converts the WHMCS staff into a PES team.... unfortunately, they have a habit of scoring own goals; passing it along the back four to play for time; ignoring comments from the paying crowd; group hugs for successfully completing a two-yard pass... and the manager has lost his voice. ⚽ 🤣 omg 7 hours ago, brian! said: btw - I think it would be useful if the comments of your hooks at least list which releases it was tested on / written for... obviously, some are v8 only, but that might not necessarily be obvious to everyone downloading. Good point 👍 I will do so 0 Quote Link to comment Share on other sites More sharing options...
ManagedCloud-Hosting Posted November 28, 2020 Author Share Posted November 28, 2020 (edited) Thank you so much @Kian I am sorry for personal reasons I was not able to check this immediately...I will check and update you... On 11/27/2020 at 8:22 PM, Kian said: I've just finsihed adding the second part. It works for me. Here is the updated version of the script. There's a new parameter ($removePDFAttachments). Set true if just want to remove PDF invoice attachments for the selected users. In this case the hook stops WHMCS from sending the email and re-send it without attachment. Let me know if it works @VirtualWorldGlobal Edited November 28, 2020 by VirtualWorldGlobal 0 Quote Link to comment Share on other sites More sharing options...
ManagedCloud-Hosting Posted December 1, 2020 Author Share Posted December 1, 2020 Dear Kian, Sorry for the delay in reply and checking as I was not well. I created the hook file and pasted the code and added a user id, then I tried sending a payment reminder to which a message displayed below the Invoice no. - Email Send Aborted By Hook. When I add user id to code the email is not sent at all. add_hook('EmailPreSend', 1, function($vars) { $disallowedEmailTemplates = array('Invoice Created'); // The name of the email template being sent $disallowedClientGroups = array(''); // Affected Client Group ID $disallowedUserIDs = array('3'); // Affected User ID $removePDFAttachments = true; // Set true if you simply want to remove PDF invoice attachments for the selected users Then I removed the user id and tried sending the email again to another user, this time also the message displayed but email was sent to client but without pdf, And the invoice amount shows - Balance Due: {$invoice_balance} not displaying the value. Then I removed the hook and email was sent with pdf as usual. Am I doing something wrong here ? On 11/27/2020 at 8:22 PM, Kian said: I've just finsihed adding the second part. It works for me. Here is the updated version of the script. There's a new parameter ($removePDFAttachments). Set true if just want to remove PDF invoice attachments for the selected users. In this case the hook stops WHMCS from sending the email and re-send it without attachment. Let me know if it works 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted December 3, 2020 Share Posted December 3, 2020 (edited) It's normal that WHMCS says "Email Send Aborted By Hook". We're aborting the sending indeed. What WHMCS doesn't know is that we're sending the email manually via phpMailer. Edited December 3, 2020 by Kian 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted December 4, 2020 Share Posted December 4, 2020 On 01/12/2020 at 18:39, VirtualWorldGlobal said: Then I removed the user id and tried sending the email again to another user, this time also the message displayed but email was sent to client but without pdf, And the invoice amount shows - Balance Due: {$invoice_balance} not displaying the value. then I suspect you would have to edit line #74 and add 'invoice_balance' to the array used in the foreach loop... foreach (array('invoice_html_contents', 'client_name', 'invoice_date_created', 'invoice_payment_method', 'invoice_num', 'invoice_total', 'invoice_date_due', 'invoice_balance', 'signature') as $v) I think it might have been better if the hook defined that array as a variable at the beginning to save you editing lines within the functions themselves. 0 Quote Link to comment Share on other sites More sharing options...
ManagedCloud-Hosting Posted December 4, 2020 Author Share Posted December 4, 2020 Hi @Kian Thank you for your reply, still the emails are not being sent out, we have updated the details for sending out emails and they are valid as the same is being used by WHMCS SMTP option, how to figure out what is wrong in this case ? 16 hours ago, Kian said: It's normal that WHMCS says "Email Send Aborted By Hook". We're aborting the sending indeed. What WHMCS doesn't know is that we're sending the email manually via phpMailer. $mail->Host = $conf['SMTPHost']; $mail->SMTPAuth = true; $mail->SMTPSecure = $conf['SMTPSSL']; $mail->Port = $conf['SMTPPort']; $mail->Username = $conf['SMTPUsername']; $mail->Password = $conf['SMTPPassword']; $mail->Mailer = 'smtp'; $mail->CharSet = 'UTF-8'; Also I need to stop 'Invoice payment Reminder' $disallowedEmailTemplates = array('Invoice Created'); // The name of the email template being sent Do I need to change anything ? Thanks 1 hour ago, brian! said: then I suspect you would have to edit line #74 and add 'invoice_balance' to the array used in the foreach loop... foreach (array('invoice_html_contents', 'client_name', 'invoice_date_created', 'invoice_payment_method', 'invoice_num', 'invoice_total', 'invoice_date_due', 'invoice_balance', 'signature') as $v) I think it might have been better if the hook defined that array as a variable at the beginning to save you editing lines within the functions themselves. Thanks @brian! I will try to add 'invoice_balance' but first I need the emails to be sent out... 0 Quote Link to comment Share on other sites More sharing options...
ManagedCloud-Hosting Posted December 9, 2020 Author Share Posted December 9, 2020 @Kian I had tried again but it's not working at my end, what could be the reason for this ? Anything that I am missing ? In my case the email sending is being stopped and it's showing the message that - 'Email sending Aborted By Hook' but the next step you mentioned where it will be resent using phpMailer is not working do I need to changed or add any information within the hook ? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted December 10, 2020 Share Posted December 10, 2020 /vendor/phpmailer/phpmailer/PHPMailerAutoload.php isn't shipped in any version of WHMCS that i'm aware of. 1 Quote Link to comment Share on other sites More sharing options...
Kian Posted December 11, 2020 Share Posted December 11, 2020 On 12/10/2020 at 6:39 PM, brian! said: /vendor/phpmailer/phpmailer/PHPMailerAutoload.php isn't shipped in any version of WHMCS that i'm aware of. It was part of PHPMailer till 2014. If you installed WHMCS before 2015 you surely have this file. Anyway nice catch. I based the hook copy-pasting an old function. I updated the hook so that it no longer uses the now-dead autoloader but loads each class file. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.