Jump to content

Conditional Display in Invoice Created email template


Kelby

Recommended Posts

54 minutes ago, Kelby said:

How to display a text if domain extension is .net in Invoice Created email template?

I don't think there would be a nice simple way to do it in the template...

you could use strstr to see if the string contains .net

{if $invoice_html_contents|strstr:".net "} do something {/if}

but that would also find .us.net, .uk.net - so if you're selling those TLDs, the above Smarty might need to be modifyied.

you will probably also have to update the Smarty Security Policy to ensure that WHMCS will allow you to use strstr in an email template.

Edited by brian!
Link to comment
Share on other sites

{if $invoice_html_contents|strstr:".net "} do something {/if}

added in email template.

 

// Smarty custom email based template policy:
$smarty_security_policy = array(
    'mail' => array(
        'php_modifiers' => array(
            'strstr',

        ),
    ),
);

Added in configuration.php

Email sent to user not include do something

 

Link to comment
Share on other sites

3 minutes ago, Kelby said:

Email sent to user not include do something

it passed the security policy, otherwise it would have been rejected... so then it's a case of working out whether $invoice_html_contents contains ".net " in your example invoice email... does it?

I can tell you that it works locally when I change the code to search for .bike and test.

RKUsOiZ.png

Link to comment
Share on other sites

1 minute ago, Kelby said:

{$order_details} contains domain.net but the email received not contains the predefined text. 

there be the problem - the invoice email templates wouldn't use {$order_details} - that's only available to the order confirmation email template...

what happens when you use $invoice_html_contents like I originally suggested ?

Link to comment
Share on other sites

3 minutes ago, Kelby said:

in Order Confirmation email. I understand the mistake!

if you're in order confirmation, then the space likely won't exist after .net, so you can remove that from the if statement... though that might cause issues depending on what TLDs you sell.

Link to comment
Share on other sites

Just now, Kelby said:

Smarty Error: Syntax error in template "mailMessage:mailMessage:plaintext" on line 16 "{if $order_details|strstr:".net"}" - Unexpected "?", expected one of: "}"

open up the email template source editor...

dLwYFNA.png

... and check in the popup window that WHMCS hasn't changed any of the above code.

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