I am creating a website with 2 store views - English and Arabic. I would like to add the language switcher inside a popup when a user opens the homepage.

But the popup need to display only once (probably by setting some cookie value or whichever is efficient).

For example, If I add the modal popup in a widget and call it in homepage, is there a way to limit the number of occurrences? Or Could anybody please help me with a better idea on how to do this. Thank you so much in advance.


You could set a cookie when showing the modal, then each time you show it, check if the cookie is already present and don't show it in that case. Just make sure to not set the cookie and then check if it is set, otherwise you would never see the modal.

The flow could be something like this:

  1. Check if the cookie is present
  2. Show the modal if not
  3. Set the cookie if it was not present

You should be able to do most of this in a custom phtml template and the cookie handling in a custom block.

| improve this answer | |
  • Thank you for the help. But s there any better way to do it? – coderaiseR Oct 9 '19 at 13:11
  • I'm afraid no, the cookie is the best option. You need to somehow recognize the user, the easiest and most reliable way to do that is with a cookie. (You could also use local storage, but that's basically the same) – kolaente Oct 10 '19 at 16:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.