yggdrasil Posted February 19, 2015 Share Posted February 19, 2015 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. 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted February 20, 2015 Share Posted February 20, 2015 looks like $clientsstats.productsnumactive is not available in "Available Merge Fields" so you may need to use hook action to make it work 0 Quote Link to comment Share on other sites More sharing options...
yggdrasil Posted February 20, 2015 Author Share Posted February 20, 2015 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? 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted February 20, 2015 Share Posted February 20, 2015 which email template you need to add this condition? 0 Quote Link to comment Share on other sites More sharing options...
yggdrasil Posted February 20, 2015 Author Share Posted February 20, 2015 which email template you need to add this condition? Domain Registrations. 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted February 21, 2015 Share Posted February 21, 2015 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"); ?> 0 Quote Link to comment Share on other sites More sharing options...
Administrators WHMCS John Posted February 22, 2015 Administrators Share Posted February 22, 2015 Hi, Thanks for your great contribution sentq. I've given this thread a more descriptive name and moved it to the Customisation & Integration forum. 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted February 22, 2015 Share Posted February 22, 2015 @John you're welcome 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.