0

In Magento2, using alpine & tailwind.css, I want to add a newsletter popup as the customer reaches the homepage on the first visit.

How can I achieve that?

2

2 Answers 2

0

I think you can use this module and customise according to your needs. https://github.com/php-cuong/magento2-newsletter-popup

0

You can use the below module

https://www.mageplaza.com/magento-2-newsletter-popup/ https://github.com/php-cuong/magento2-newsletter-popup

and for the first time load can set cookies with the help of below functions

        function setCookie(cname,cvalue,exdays) {
              var d = new Date();
              d.setTime(d.getTime() + (exdays*24*60*60*1000));
              var expires = "expires=" + d.toGMTString();
              document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
          }

          function getCookie(cname) {
              var name = cname + "=";
              var ca = document.cookie.split(';');
              for(var i = 0; i < ca.length; i++) {
                  var c = ca[i];
                  while (c.charAt(0) == ' ') {
                      c = c.substring(1);
                  }
                  if (c.indexOf(name) == 0) {
                      return c.substring(name.length, c.length);
                  }
              }
              return "";
          }

          function checkCookie(cname) {
              var user=getCookie(cname);
              if (user != "") {
                  return "1";
              } else {
                  return "0";
              }
          }

 var popupShow = checkCookie("mobile_login_popup_show");
                if(popupShow != "1") {
                   // your popup load code
               
                    setCookie("mobile_login_popup_show", 1, 1);
                }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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