Jump to content

how to dynamically set suspension notice in templates?


dippa

Recommended Posts

Hi, for overdue email templates, I would like a suspension notice to appear, but only if the overdue invoice is for a hosting product. For custom invoices I don't want a suspension notice to appear. I have tried using some 'if' statements but I'm not sure which variable I should be checking.

 

So what I need in the email template is something along the lines of:

 

{if $product_type eq "Hosting"}

Your hosting will be suspended in 7 days

{/if}

Link to comment
Share on other sites

Wait so you want the text on the overdue email itself, right? Not a new termination letter?

 

Yes that is correct, I would like to be able to write the text on the overdue email itself. But needs to be for hosting products only. Some overdue invoices wouldn't make sense to have a suspension notice on it, such as custom invoices. So what conditional do I need to write to do that? Thanks

Link to comment
Share on other sites

So what conditional do I need to write to do that?

there isn't a guaranteed simple way to do this in the invoice email templates where you don't have direct access to the product info...

 

if your hosting product's names contains strings you can search for (the obvious ones being if the product name contains "Hosting" or "Account", then you could search the $invoice_items array for these words and if found using it as a trigger to add a suspension warning... though there is always the risk of errors (e.g if someone has ordered a domain containing that keyword).

 

if they don't, then you'd probably be looking at writing an action hook to query the invoices database table to detect the product type.

Link to comment
Share on other sites

Thank you, can you please show me how to write an example conditional using $invoice_items

it turns out that there is a guaranteed simple way using $invoice_items ! :)

 

{foreach key=num item=invoiceitem from=$invoice_items}
{if $invoiceitem.type eq "Hosting"}Your hosting account will be suspended in 7 days{break}{/if}
{/foreach}

this loops through the invoiceitems array... if it finds a product type of "Hosting", it adds the suspension text to the email and stops the loop - if it's a domain/addon/custom etc, it doesn't add anything.

 

i've added the {break} so that it only displays the suspension message once - if you remove it, and if the invoice has two or more hosting accounts, it would display the message multiple times... if you could add the specific domain to the suspension message that would be useful, but there's no easy way to get it (other than perhaps by regex-ing the description field or querying the db)...

 

hopefully, it's something that you won't need to do! :idea:

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