0

I have displayed a custom message in a popup for the logged out customer in Magento 2.

For example what I have done so far.

  1. Once they click the "sign out" button, I have shown the popup to them.
  2. But Once they close the popup, I just need to allow the customer to proceed with the sign out button.
  3. And I don't want them to show the popup again to the same customer on the same day.
  4. But the next day, I need to show the popup to the customer.

Actually my requirement is don't want to show the popup again and again to the same customer on the same day.

Thanks in advance

4
  • Use cookie concept , you can set cookie and its expire time , on click the close button set the cookie value as 1 , and before the pop up display function check if cookie does not equal to 1. Commented Apr 7, 2020 at 18:31
  • @HamendraSunthwal, Can you give example?
    – Jaisa
    Commented Apr 7, 2020 at 18:37
  • 1
    Thank you for the response
    – Jaisa
    Commented Apr 7, 2020 at 18:41
  • I have added an answer & i have told you the logic , by which you can achieve the functionality that you've asked in the question. Commented Apr 7, 2020 at 18:43

1 Answer 1

0

Use cookie concept , you can set cookie and its expire time , on click the close button set the cookie value as 1 , and before the pop up display function check if cookie does not equal to 1.

You can set cookie like this.

<script type="text/javascript">
require([
    'jquery',
    'jquery/jquery.cookie'
], function ($) {
    $(document).ready(function () {

        var check_cookie = $.cookie('foo'); // Get Cookie Value
        var date = new Date();
        var minutes = 60;
        date.setTime(date.getTime() + (minutes * 60 * 1000));
        $.cookie('foo', '', {path: '/', expires: -1}); // Expire Cookie
        $.cookie('foo', 'bar', {expires: date}); // Set Cookie Expiry Time
        $.cookie('foo', 'setvalue'); // Set Cookie Value
    }
});

1
  • Thanks for the immediate response. Will try and let you know
    – Jaisa
    Commented Apr 7, 2020 at 18:47

Your Answer

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

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