mihai666g Posted February 27, 2020 Share Posted February 27, 2020 Hi, I trying to display a notification on configuredomains.tpl page if the client order a .de domain I managed to get it working but because I use foreach the message is displayed multiple times if the client has multiple domains with that extension {if $domains} {foreach $domains as $num => $domain} {if strpos($domain.domain, '.de') !== false} code {/if} {/foreach} {/if} Since I have no programming experience I don't know how to store the domains in a variable/string so I can get rid of foreach Any tips are appreciated. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 28, 2020 Share Posted February 28, 2020 14 hours ago, mihai666g said: Since I have no programming experience I don't know how to store the domains in a variable/string so I can get rid of foreach you wouldn't need to store them in a variable. if you only want to display this message once, regardless of how many .de domains there are in the cart, and you want to do it using Smarty in the template, then you could add a counter variable.... {if $domains} {foreach $domains as $num => $domain} {if strpos($domain.domain, '.de') !== false && $domaincount == 0} {assign domaincount 1} code{/if} {/foreach} {/if} it loops through the array, if it finds a .de domain for the first time, it displays your message and creates a counter variable - because of the if statement, that then prevents the message being shown again regardless of how many other .de domains there are. 1 Quote Link to comment Share on other sites More sharing options...
mihai666g Posted February 28, 2020 Author Share Posted February 28, 2020 4 hours ago, brian! said: it loops through the array, if it finds a .de domain for the first time, it displays your message and creates a counter variable - because of the if statement, that then prevents the message being shown again regardless of how many other .de domains there are. Thanks, that's what I wanted. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 28, 2020 Share Posted February 28, 2020 13 minutes ago, mihai666g said: Thanks, that's what I wanted. btw - it's not essential to change it, but I don't think you would need the {if $domains} and the closing {/if} because if there are no domains in the $domains array, you wouldn't be directed to the configuredomains page in the cart process. 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.