Jump to content

getting list of all domains in one variable


mihai666g

Recommended Posts

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. 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 
 
 
 
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. 
 

Link to comment
Share on other sites

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.

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