def Posted September 2, 2014 Share Posted September 2, 2014 Dear support, i have this need; I use whmc for some of the many features available. Unfortunatly we have a separate invoicing software and for business need we need to keep it. I wonder to disable Invoice generation in whmcs but I can't find how to. When our user make an order, immediatly whmcs generate a new invoice. The problem is that clients sees warning about this invoice in they client area until we have manually cancelled that invoice. Some customer notice them and this is not well. We stop every invoice-related stuff,like auto cc, invoice reminder, email and so on, but invoices are generated on every order immediatly. So, we need to stop invoice auto-generation how can we reach this goal? Or is it possibile to automatic cancel invoices immediatly after generation? thanks in advance Matteo Lombardi Defende Sas 0 Quote Link to comment Share on other sites More sharing options...
SeanP Posted September 2, 2014 Share Posted September 2, 2014 You could create a hook to prevent invoice emails, and mark the invoices as canceled. I have not tested this, but this hook should work. Just create a file called "preventinvoices.php" in your includes/hooks folder, with the following contents: <?php if (!defined("WHMCS")) die("This file cannot be accessed directly"); function prevent_invoices($vars) { // WHMCS admin user for API $adminuser = 'WHMCSADMINUSER'; // Get name of the email template $email_template_name = trim($vars['messagename']); // Get invoice ID $relid = $vars['relid']; // Create array to abort messages $merge_fields = array(); // Abort invoice messages and cancel invoice if ($email_template_name == 'Invoice Payment Confirmation' || $email_template_name == 'Invoice Created') { $merge_fields['abortsend'] = true; ##### Start API Update ##### $command = "updateinvoice"; $values["invoiceid"] = $relid; $values["notes"] = "Invoice is issued by another system."; $values["status"] = "Cancelled"; $results = localAPI($command,$values,$adminuser); ##### End Admin Password API Call ##### } return $merge_fields; } add_hook("EmailPreSend",1,"prevent_invoices"); ?> Make sure to set the "adminuser" variable to a valid admin user that has "API Access" permissions. This will prevent invoices and payment confirmation emails from being sent, along with marking the invoice as canceled. 0 Quote Link to comment Share on other sites More sharing options...
def Posted September 3, 2014 Author Share Posted September 3, 2014 hi, thanks for you reply. we tried but nothing as changed invoices are "unpaid" maybe because we have disabled every email template or email about invoices to customers? it's possibile to trigger the order confermation for start the invoice cancel? when placing an order system log look ad this example: Updated Stored Credit Card Details - User ID: 24 Email Sent to xxxxxxxxxxxxxx(Order confirmation)- User ID: 24 Created Invoice - Invoice ID: 423 New Order Placed - Order ID: 294 - User ID: 24 ---- also we see that custerm see the link to the invoice at checkout even if we mark "Just show the order completed page (no payment redirect)" ... thanks again 0 Quote Link to comment Share on other sites More sharing options...
def Posted September 3, 2014 Author Share Posted September 3, 2014 update: we have modified the clientareahome.tpl and commented the "box"; same as for complete.tpl in order template. we still have invoice but customers can't see that 0 Quote Link to comment Share on other sites More sharing options...
SeanP Posted September 3, 2014 Share Posted September 3, 2014 (edited) If you have already taken care of preventing the invoice emails, try the following hook (replace the contents of "includes/hooks/preventinvoices.php" with the code below). As stated before, make sure to update the "adminuser" variable with an admin account that has "API Access" rights. This should run right after an invoice is created, and mark it as canceled. <?php if (!defined("WHMCS")) die("This file cannot be accessed directly"); function prevent_invoices($vars) { // WHMCS admin user for API $adminuser = 'WHMCSADMINUSER'; // Get invoice ID $invoiceid = $vars['invoiceid']; ##### Start API Update ##### $command = "updateinvoice"; $values["invoiceid"] = $invoice; $values["notes"] = "Invoice is issued by another system."; $values["status"] = "Cancelled"; $results = localAPI($command,$values,$adminuser); ##### End Admin Password API Call ##### } add_hook("InvoiceCreationPreEmail",1,"prevent_invoices"); ?> Edited September 3, 2014 by SeanP 0 Quote Link to comment Share on other sites More sharing options...
def Posted September 4, 2014 Author Share Posted September 4, 2014 thank you but it doesn't work... (adminuser set correclty) Am I doing something wrong? what can I do to very how it does not work? thanks again 0 Quote Link to comment Share on other sites More sharing options...
def Posted September 4, 2014 Author Share Posted September 4, 2014 ops *verify 0 Quote Link to comment Share on other sites More sharing options...
SeanP Posted September 4, 2014 Share Posted September 4, 2014 Sorry... Typo. Change the line that reads: $values["invoiceid"] = $invoice; to: $values["invoiceid"] = $invoiceid; I just tested it on my dev server, and it cancels the invoices upon creation. 0 Quote Link to comment Share on other sites More sharing options...
def Posted September 5, 2014 Author Share Posted September 5, 2014 nothing <?php if (!defined("WHMCS")) die("This file cannot be accessed directly"); function prevent_invoices($vars) { // WHMCS admin user for API $adminuser = 'XXXXXXX'; // Get invoice ID $invoiceid = $vars['invoiceid']; ##### Start API Update ##### $command = "updateinvoice"; $values["invoiceid"] = $invoiceid; $values["notes"] = "Invoice is issued by another system."; $values["status"] = "Cancelled"; $results = localAPI($command,$values,$adminuser); ##### End Admin Password API Call ##### } add_hook("InvoiceCreationPreEmail",1,"prevent_invoices"); ?> invoices are not cancelled -.- maybe anything is disabled on my system? 0 Quote Link to comment Share on other sites More sharing options...
SeanP Posted September 5, 2014 Share Posted September 5, 2014 (edited) Did you create the "preventinvoices.php" under the includes/hooks folder? You might try using a different hook point by changing the following line: add_hook("InvoiceCreationPreEmail",1,"prevent_invoices"); to add_hook("InvoiceCreated",1,"prevent_invoices"); Edited September 5, 2014 by SeanP 0 Quote Link to comment Share on other sites More sharing options...
def Posted September 5, 2014 Author Share Posted September 5, 2014 it works!!! thank you a lot Matteo 0 Quote Link to comment Share on other sites More sharing options...
SeanP Posted September 5, 2014 Share Posted September 5, 2014 No problem. I'm glad to hear it is working for you. 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.