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?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityIn 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?
I think you can use this module and customise according to your needs. https://github.com/php-cuong/magento2-newsletter-popup
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);
}