0

define([ "jquery", 'Magento_Ui/js/modal/modal' ], function($,modal){ return function storeswitcher(config, element) { var modaloption = { type: 'popup', modalClass: 'modal-popup', responsive: true, innerScroll: true, clickableOverlay: true, title: 'Simple Modal', buttons: [{ text: $.mage.(yesbutton), class: 'modal-Yes', click: function (){ window.location = window.url; } }, { text: $.mage.(nobutton), class: 'modal-No', click: function (){ this.closeModal(); } }] }; var callforoption = modal(modaloption, $('.callfor-popup')); $('.callfor-popup').modal('openModal'); } function getUrl(){ window.url; } });

1

You can use the localStorage to check

try this code

define(["jquery", 'Magento_Ui/js/modal/modal'], function($, modal) {
return function storeswitcher(config, element) {
    var modaloption = {
        type: 'popup',
        modalClass: 'modal-popup',
        responsive: true,
        innerScroll: true,
        clickableOverlay: true,
        title: 'Simple Modal',
        buttons: [{
            text: $.mage.(yesbutton),
            class: 'modal-Yes',
            click: function() {
                window.location = window.url;
            }
        }, {
            text: $.mage.(nobutton),
            class: 'modal-No',
            click: function() {
                this.closeModal();
            }
        }]
    };
    var callforoption = modal(modaloption, $('.callfor-popup'));
    $('.callfor-popup').modal('openModal');

    if (!localStorage.getItem('popupShown')) {
        $('.callfor-popup').modal('openModal');
        localStorage.setItem('popupShown', true);
    }
}

function getUrl() {
    window.url;
}

});

2
  • bharat thank you Jul 19 at 13:43
  • It is working then accept answer..
    – bharat
    Oct 14 at 13:33

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.