Jump to content

Domain renewal reminders tweak


Recommended Posts

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.

Link to comment
Share on other sites

  • 5 months later...

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");

Link to comment
Share on other sites

  • 3 weeks later...
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 by CDJ Hosting
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