MBayDesign Posted April 3, 2017 Share Posted April 3, 2017 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! 0 Quote Link to comment Share on other sites More sharing options...
MBayDesign Posted April 7, 2017 Author Share Posted April 7, 2017 Well, perhaps the lack of response is that the hook works, the one that's linked to; however, when I tried it before, it hosed my site. So, after a slight edit, problem solved and the link to the hook noted does work. 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.