Jump to content

hook help - prevent $0 invoice


Recommended Posts

I've got a product setup to establish Quarterly Maintenance service using autorelease, $0.00 quarterly and an email marketing rule that spits out a reminder that maintenance will be performed based on the due date. I then invoice manually because it's different every time.

 

The marketing rule portion works great, but I'm obviously trying to prevent the $0 invoice from being sent and support directed me to the EmailPreSend hook. (I'm still not sure why preventing $0 invoices isn't baked into WHMCS as an option, but it's obviously not.)

 

I have fumbled with various iterations of code, including using this portion to select from the DB which I found here:

 

$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')

 

All my choices were wildly incorrect. This is another version that also didn't work:

 

<?php

add_hook('EmailPreSend', 1, function($vars) {
   $merge_fields['invoice_total'] = "$0.00";
   if ($vars['messagename'] =='Credit Card Invoice Created' && $vars['relid'] == 22) {
       //Stop the email from sending a specific message and related id.
       $merge_fields['abortsend'] = true;
   }
   return $merge_fields;
});

 

I had hopes, but this didn't work either. This seems like it should be such a simple code, but I’m obviously missing something…

 

Help most appreciated - thanks!

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