0

This is causing newsletter to popup on every page and every time I refresh the page , even after subscribing . :( Can someone tell me what should I add, delete or change in this so that it displays popup only one time? from the path

public_html/app/code/CleverSoft/Newsletter/view/frontend/templates/newsletter/

I have found a file

subscribe.phtml In this file the code is

            <div class="hidden-xs hidden-sm col-md-6 zoo-logo-newsletter"></div>
        <?php }?>
        <div class="zoo-popup-newsletter-inner col-md-6 <?php if($backgroundImage) echo 'col-md-12'; ?>">
            <h2>
                <span><?php echo __('Newsletter') ?></span></strong>
            </h2>
            <div class="row-none">
                <div class="popup_message">
                    <p class="intro">
                        <?php echo $desc; ?>
                    </p>
                    <form action="<?php echo $this->getFormActionUrl() ?>" method="post"
                          id="zoo-newsletter-validate-detail" novalidate
                          data-mage-init='{"validation": {"errorClass": "mage-error"}}'>


                        <div class="block-content form-groups">

                            <input name="email" type="text" id="zoo-newsletter"
                                   class="input-text required-entry validate-email"
                                   value="<?php echo __('Your email address') ?>"
                                   onclick="this.value=='<?php echo __('Your email address') ?>'?this.value='':''"
                                   onblur="this.value==''?this.value='<?php echo __('Your email address') ?>':''"
                                   data-validate="{required:true, 'validate-email':true}"/>
                            <button type="submit"  class="btn-novetty">
                                <?php echo __('Subscribe') ?></button>
                        </div>
                    </form>
                </div>
            </div>
            <div class="block-content">
                <label class="subcriper_label checkbox-filter">
                    <input type="checkbox">
                    <span class="checkbox-material"><span class="check"></span></span>
                    <?php echo __('Don\'t show this popup again'); ?>
                </label>
            </div>
            <script>
                require([
                    "jquery",
                    'Magento_Ui/js/modal/modal',

                    "jquery/jquery.cookie"
                ], function(  $, modal  ) {
                    //<![CDATA[
                    $(function () {
                        function setCookie(cname, cvalue, exdays) {
                            var d = new Date();
                            d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
                            var expires = "expires="+d.toUTCString();
                            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 null;
                        }

                        var subscribeFlag = getCookie('cleverNewsletterSubscribeFlag');

                        $('#zoo_newsletter .subcriper_label input').on('click', function () {
                            if ($(this).parent().find('input:checked').length > 0) {
                                setCookie('cleverNewsletterSubscribe','true',2147483647);
                            } else {
                                setCookie('cleverNewsletterSubscribe',null,1);
                            }
                        });

                        $('#zoo_newsletter button.btn-novetty').on('click', function () {
                            var button = $(this);
                            setTimeout(function () {
                                if (!button.parent().find('input#zoo-newsletter').hasClass('validation-failed')) {
                                    setCookie('cleverNewsletterSubscribeFlag','true',2147483647);
                                }
                            }, 500);
                        });

                        if (!(subscribeFlag) && !getCookie('cleverNewsletterSubscribe')) {
                            var options = {
                                type: 'popup',
                                modalClass: 'zoo-newsletter-popup',
                                responsive: true
                            };
                            var popup = modal(options, $('#zoo_newsletter'));
                            setTimeout(function(){
                                $('#zoo_newsletter').modal('openModal');
                            },<?php echo $delay; ?>);

                        }
                    });
                    //]]>
                })

            </script>
        </div>
    </div>
</div>
  • Just look into your admin config section there must be something for managing this popup module – Abhishek Tripathi Feb 27 '18 at 7:17
  • there is only newsletter delay option. however, i want popup to display only once a person opens website. – Laiba Feb 27 '18 at 7:19
  • do you have cookies disabled? Can you see/examine the cookie? – Scott Jun 25 '18 at 20:11
  • btw, leave it to cleversoft to re-design the wheel and add redundant code when there's already a CookieHelper with get/set functions in lib/web/mage/cookies.js – Scott Jun 25 '18 at 21:09

Your Answer

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

Browse other questions tagged or ask your own question.