Jump to content

How to use productsnumactive in domain registration email template?


yggdrasil

Recommended Posts

In the documentation it says conditional in emails are the same as templates except they don't seem to work.

 

Example:

 

{if $clientsstats.productsnumactive eq 0} my domain is {$domain_name}

 

Text here

 

{/if}

 

This does not work.

 

I also tried lt or neq, it doesn't matter, the conditional will not work in the email but does in templates.

 

I want to display a text in some emails send only for users that have domains alone, but not products.

Link to comment
Share on other sites

looks like $clientsstats.productsnumactive is not available in "Available Merge Fields" so you may need to use hook action to make it work

 

But then I'm correct. The conditionals don't work. I don't want to use hooks for this but conditionals. Is there any conditional which checks if users have products active or not?

Link to comment
Share on other sites

do the following and it will work for you, create new file in /includes/hooks/ directory with any name like emaildomainreg.php

and put this code inside it:

<?php

function hook_emailActiveProducts($vars){
   if ($vars['messagename']=="Domain Registration Confirmation"){
       $getUserID = full_query("SELECT `userid` FROM `tbldomains` WHERE `id`='".$vars['relid']."'");
       $getUserID = mysql_fetch_assoc($getUserID);
       $userid = $getUserID['userid'];

       $activeProducts = full_query("SELECT `domainstatus` FROM `tblhosting` WHERE `userid`='{$userid}'");
       $activeProducts = mysql_num_rows($activeProducts);

       if ($activeProducts!='0'){
           return array("hasActiveProducts" => true);
       } else {
           return array("hasActivePruducts" => false);
       }
   }
}
add_hook("EmailPreSend", 1, "hook_emailActiveProducts");

?>

 

now go to your email template that you need to modify in our case it will be "Domain Registration Confirmation" and add the condition as follow:

{if $hasActiveProducts}
<b>Client Has Active Product(s)</b>
{else}
<b>No Active Product found for this client</b>
{/if}

 

i hope this was easy and help you with what you need, let me know the result please :)

 

- - - Updated - - -

 

unable to edit my post, updated the hook action code:

<?php

function hook_emailActiveProducts($vars){
   if ($vars['messagename']=="Domain Registration Confirmation"){
       $getUserID = full_query("SELECT `userid` FROM `tbldomains` WHERE `id`='".$vars['relid']."'");
       $getUserID = mysql_fetch_assoc($getUserID);
       $userid = $getUserID['userid'];

       $activeProducts = full_query("SELECT `id` FROM `tblhosting` WHERE `userid`='".$userid."' AND `domainstatus`='Active'");
       $activeProducts = mysql_num_rows($activeProducts);

       if ($activeProducts!='0'){
           return array("hasActiveProducts" => true);
       } else {
           return array("hasActivePruducts" => false);
       }
   }
}
add_hook("EmailPreSend", 1, "hook_emailActiveProducts");

?>

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