Jump to content

Custom {if} on invoice & payment reminder email templates for hosting clients only


valeriec

Recommended Posts

I haven't found quite the solution here in the forums.

 

I have started using WHMCS for all of my billing: web hosting, domains, printing, design, web packages, etc.

 

I'd like, on the invoice and reminders, to display a block of text only for hosting and domain invoices that reminds the client that there is a re-activation fee if their hosting account is not paid on time. I don't want this block on other invoices as several clients have said they are a bit offended reading it when it has nothing to do with them.

 

I tried:

 

{if $service_id eq '1'}
[b]Important![/b]
If your payment is not received by {$invoice_date_due}, your account will automatically be suspended. There is a $75 non-refundable fee to re-instate your account and restore your files.
{/if}

 

Ideally, I'd also like to avoid sending multiple reminders to non-hosting/domain customers, but I can live with that.

Link to comment
Share on other sites

If life were so easy there would be nothing here to learn :)

 

This approach requires you to enter product group IDs for specific products.

 

For example, if you want to show that notice of yours to users with web hosting packages and web design services + domain renewals, you need to enter GID numbers for those product groups. Domains are triggered directly.

 

So, in this example your notice will be added to every invoice email containing domain renewals or products nested inside product groups with IDs 3, 9 and 14...

 

Place this at the top of your invoice email template:

{foreach key=num from=$invoice_items item=invoiceitem}
   {if $invoiceitem.type eq "Hosting"}
     {php}
       // ENTER PRODUCT GROUP IDs YOU WANT TO TRIGGER THE ALERT
       $productsGroups = Array("3", "9", "14");

       $relid = $this->_tpl_vars['invoiceitem']['relid'];
       $join = "tblproducts ON tblproducts.id=tblhosting.packageid";
       $select = select_query("tblhosting","tblproducts.gid",array("tblhosting.id"=>$relid),'gid','ASC','1',$join);
       $data = mysql_fetch_array($select);
       if (in_array($data[0], $productsGroups)) $this->_tpl_vars['trigger'] = 1;
     {/php}
   {/if}
{/foreach}

 

Place this where you want to your notice to appear...

 

{if $trigger eq "1" or $invoiceitem.type eq "Domain"}
Important!
If your payment is not received by {$invoice_date_due}, your account will automatically be suspended. There is a $75 non-refundable fee to re-instate your account and restore your files.
{/if}

Link to comment
Share on other sites

  • 2 weeks later...

Help me pls - I do need this:

 

In an email (letter) which is send to a client there is a link. WHMCS (while sending this email/letter) should first see if the letter is related to a product from a certain product group (or at least: if the letter is related to a product with the title NNN or MMM). If it IS related - than WHMCS should put there (in the letter) a certain link (link #1). If it is NOT related or if the letter can not have any product related - see below:

 

If the client has a product from a certain product group (or at least: has a product with the title NNN or MMM) - than WHMCS should put there (in the letter) a certain link (link #1). If NOT - WHMCS should put there (in the letter) another link (link #2).

 

That is all I need :)

 

P.S.- your code here (above) is nice but it works only for new orders but not for changing plans, for example (in the invoice for updating the plan this code does not work). So it needs to be modified some how...

Link to comment
Share on other sites

Try something like this:

 

{foreach key=num from=$invoice_items item=invoiceitem} 
   {if $invoiceitem.type eq "Hosting" OR $invoiceitem.type eq "Upgrade"} 
     {php} 
       // ENTER PRODUCT GROUP IDs YOU WANT TO TRIGGER THE ALERT 
       $productsGroups = Array("5", "9", "14"); 

       $relid = $this->_tpl_vars['invoiceitem']['relid']; 
       $type = $this->_tpl_vars['invoiceitem']['type']; 

       if($type=="Upgrade") 
         $select = full_query("SELECT tblproducts.gid FROM tblhosting JOIN tblproducts ON tblproducts.id=tblhosting.packageid WHERE tblhosting.id IN (SELECT relid FROM tblupgrades WHERE id=$relid)");
       else 
         $select = full_query("SELECT tblproducts.gid FROM tblhosting JOIN tblproducts ON tblproducts.id=tblhosting.packageid WHERE tblhosting.id IN ($relid)");

       $data = mysql_fetch_array($select); 
       if (in_array($data[0], $productsGroups)) $this->_tpl_vars['trigger'] = 1; 
     {/php} 
   {/if} 
{/foreach}  



{if $trigger eq "1" or $invoiceitem.type eq "Domain"} 
Important! 
If your payment is not received by {$invoice_date_due}, your account will automatically be suspended. There is a $75 non-refundable fee to re-instate your account and restore your files. 
{/if}  

Link to comment
Share on other sites

You must be a WHMCS genius! Thank you :)

 

But just 2 more questions:

1) Tickets. I would like the clients (who have a product from the certain group) get $trigger == 1. If no such product - so don't alert the trigger. Is it possible?

 

2) Domains. The same as tickets. So if the client has a product (from the group that alerts the trigger) - he gets $trigger == 1 (even for example at a domain mail templates (even those which are related to domains only)). But if not - so don't alert the trigger. Now it is for any domain (or $invoiceitem.type eq "Domain") but I want for only those situations when the client has a product from that group...

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.

×
×
  • 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