Kelby Posted June 1, 2020 Share Posted June 1, 2020 Hello, How to display a text if domain extension is .net in Invoice Created email template? Thanks 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 1, 2020 Share Posted June 1, 2020 (edited) 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 June 1, 2020 by brian! 0 Quote Link to comment Share on other sites More sharing options...
Kelby Posted June 1, 2020 Author Share Posted June 1, 2020 So I need to add // Smarty custom email based template policy: $smarty_security_policy = array( 'mail' => array( 'php_modifiers' => array( 'strstr', ), ), ); in configuration.php? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 1, 2020 Share Posted June 1, 2020 9 minutes ago, Kelby said: So I need to add... in configuration.php? yes - it won't work until you do. 0 Quote Link to comment Share on other sites More sharing options...
Kelby Posted June 1, 2020 Author Share Posted June 1, 2020 {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 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 1, 2020 Share Posted June 1, 2020 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. 0 Quote Link to comment Share on other sites More sharing options...
Kelby Posted June 1, 2020 Author Share Posted June 1, 2020 {$order_details} contains domain.net but the email received not contains the predefined text. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 1, 2020 Share Posted June 1, 2020 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 ? 0 Quote Link to comment Share on other sites More sharing options...
Kelby Posted June 1, 2020 Author Share Posted June 1, 2020 I added {if $invoice_html_contents|strstr:".net "} do something {/if} under {$order_details}. the text do something not added to the email sent. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 1, 2020 Share Posted June 1, 2020 but {$order_details} isn't used in an invoice email - are you trying to do this in the invoice created email or the order confirmation email ?? 0 Quote Link to comment Share on other sites More sharing options...
Kelby Posted June 1, 2020 Author Share Posted June 1, 2020 (edited) in Order Confirmation email. I understand the mistake! Edited June 1, 2020 by Kelby 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 1, 2020 Share Posted June 1, 2020 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. 1 Quote Link to comment Share on other sites More sharing options...
Kelby Posted June 1, 2020 Author Share Posted June 1, 2020 (edited) In Order Confirmation {if $order_details |strstr:".net"} do something {/if} right? Edited June 1, 2020 by Kelby 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 1, 2020 Share Posted June 1, 2020 2 minutes ago, Kelby said: In Order Confirmation {if {$order_details} |strstr:".net"} do something {/if} right? you won't need the brackets around order_details.. {if $order_details|strstr:".net"} do something {/if} 1 Quote Link to comment Share on other sites More sharing options...
Kelby Posted June 1, 2020 Author Share Posted June 1, 2020 Smarty Error: Syntax error in template "mailMessage:mailMessage:plaintext" on line 16 "{if $order_details|strstr:".net"}" - Unexpected "?", expected one of: "}" 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 1, 2020 Share Posted June 1, 2020 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... ... and check in the popup window that WHMCS hasn't changed any of the above code. 1 Quote Link to comment Share on other sites More sharing options...
Kelby Posted June 1, 2020 Author Share Posted June 1, 2020 Awesome! It works! @brian! the genius! 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.