swilders Posted December 17, 2012 Share Posted December 17, 2012 Our clients pay us on 30 day terms. They get a domain renewal reminder, they confirm they want it renewing so we renew it and invoice them. They pay in approximately 30 days time. The problem with WHMCS is that even though it is renewed, it still sends domain renewal reminders until it is paid. These renewals look silly anyway because they say, for example, that the domain is going to expire in 737 days! The reminders should be based on the domain expiry date not the next due date. WHMCS advised us to write an action hook to stop the email is this situation. We've tried to set this up but This doesn't seem to work. function domain_expiry_2($vars) { $daysuntilrenewal=$vars['domain_days_until_expiry']; $merge_fields=array(); if($daysuntilrenewal>=60) $merge_fields['abortsend']=true; return $merge_fields; } add_hook("EmailPreSend",1,"domain_expiry_2"); Please can you quote to write a working version of this. 0 Quote Link to comment Share on other sites More sharing options...
GORF Posted December 22, 2012 Share Posted December 22, 2012 Or just don't set your due and expiration dates so far apart. 0 Quote Link to comment Share on other sites More sharing options...
And then there was one les Posted June 4, 2013 Share Posted June 4, 2013 Inbox me if you still need this 0 Quote Link to comment Share on other sites More sharing options...
swilders Posted June 5, 2013 Author Share Posted June 5, 2013 Hello, I did get this working in the end. It might not be the most elegant solution but $vars doesn't include the required information to make the decision without a database query. This works fine for us though: function domain_expiry_2($vars) { $merge_fields=array(); if($vars['relid']&&$vars['messagename']=='Upcoming Domain Renewal Notice') { $daysuntilrenewal=mysql_fetch_array(mysql_query("SELECT DATEDIFF(expirydate,'".date("Y-m-d")."') FROM tbldomains WHERE id=".$vars['relid'])); if($daysuntilrenewal[0]>=60) $merge_fields['abortsend']=true; } return $merge_fields; } add_hook("EmailPreSend",1,"domain_expiry_2"); 0 Quote Link to comment Share on other sites More sharing options...
And then there was one les Posted June 26, 2013 Share Posted June 26, 2013 (edited) Hello, I did get this working in the end. It might not be the most elegant solution but $vars doesn't include the required information to make the decision without a database query. This works fine for us though: function domain_expiry_2($vars) { $merge_fields=array(); if($vars['relid']&&$vars['messagename']=='Upcoming Domain Renewal Notice') { $daysuntilrenewal=mysql_fetch_array(mysql_query("SELECT DATEDIFF(expirydate,'".date("Y-m-d")."') FROM tbldomains WHERE id=".$vars['relid'])); if($daysuntilrenewal[0]>=60) $merge_fields['abortsend']=true; } return $merge_fields; } add_hook("EmailPreSend",1,"domain_expiry_2"); function domain_expiry_2($vars) {# shouldn't be needed $merge_fields array already exists. $merge_fields=array(); if($vars['relid'] && $vars['messagename'] == 'Upcoming Domain Renewal Notice') {# calling the query inside the fetch_array means the query is recalled time and again as the fetch array loops, you only want it called once. $query = mysql_query("SELECT DATEDIFF(expirydate,'".date("Y-m-d")."') FROM tbldomains WHERE id=".$vars['relid']); # change to row, no point using fetch_array/assoc here as its a single row you need. $daysuntilrenewal = mysql_fetch_row($query); if($daysuntilrenewal[0] >= 60) { # instead of ommitting curly braces you are better to just use them and save confusion later because ommiting them means only the next line is affected by the if clause. $merge_fields['abortsend'] = true;}}return $merge_fields; } add_hook("EmailPreSend",1,"domain_expiry_2"); Edited June 26, 2013 by CDJ Hosting 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.