Jump to content

how to stop invoice generation?


def

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by SeanP
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 by SeanP
Link to comment
Share on other sites

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