1

In magento Home page display Once the customer clicks checkbox in the popup. It should close the popup and should not pop again.

New contributor
GOKUL I is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
1

You can try this way:

<div id="custom-popup-modal">
    <ul id="checkBundle">
        <li><label><input id="dont" type="checkbox" />Dont Show Popup Again</label>
    </ul>
</div>


<script>
    require(
        [
            'jquery',
            'Magento_Ui/js/modal/modal'
        ],
        function(
            $,
            modal
        ) {
            var options = {
                type: 'popup',
                responsive: true,
                innerScroll: true,
                //title: 'popup modal title',
                buttons: [{
                    text: $.mage.__('Continue'),
                    class: '',
                    click: function () {
                        this.closeModal();
                    }
                }]
            };
            var popup = modal(options, $('#custom-popup-modal'));
            if (!localStorage.getItem('popupShown')) {
                $('#custom-popup-modal').modal('openModal');

                $("#dont").click(function(){
                    localStorage.setItem('popupShown', true);
                });
            }
        }
    );
</script>

In the above code, we are checking whether the cookie is stored in the localstorage. If it is not stored in the local storage we are calling our modal popup. Only after clicking the checkbox, the cookie will be stored in the local storage.

Your Answer

GOKUL I is a new contributor. Be nice, and check out our Code of Conduct.

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.