• Resolved SRD75

    (@srd75)


    Hi Folks,

    On our page, we have two buttons;

    produced by code:

    <p><img src="https://mandoestage.wpengine.com/wp-content/uploads/2022/06/change-countries.svg" alt="change countries?" /></p>
    <h3>Are you visiting Mandoe from outside your region?</h3>
    <p>Visit your regional site for more relevant pricing, promotions and events.</p>
    <p id="geo-buttons"><a id="geo-target" class="geo-button" onclick="redirect()" style="color: black;">Visit AUS</a>&nbsp;&nbsp;&nbsp; <a id="geo-close" class="geo-button">Visit US</a></p>
    <script>
    function redirect(){
        var loc = window.location;
        var pathname = loc.pathname;
        var AustralianSite = 'https://mandoestage.wpengine.com/en-au';
        var finalURL = AustralianSite + pathname;
        window.location.href = finalURL;
    }
    jQuery( document ).ready(function() {
        jQuery("#geo-close").click(function() {
             jQuery(".spu-container").hide(); 
        });
    });
    </script>

    How do I add another function to jQuery("#geo-close").click to set a cookie to remember the popup has been closed, the same way clicking the cross @ top right does.

    Help appreciated.
    Steve

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Damian

    (@timersys)

    Hi @srd75 !

    What you need to look is the https://wppopups.com/docs/javascript-functions/ in order to close and place a cookie either for conversion or closing cookie.

    Close the popup and set closing cookie

        jQuery("#geo-close").click(function() {
             // replace popup_id with the ID of the popup you are targeting. 
             // true will close it as conversion, set to false to set closing cookie instead
             wppopups.hidePopup(popup_id, true); 
        });
    Thread Starter SRD75

    (@srd75)

    Legend, thank you @timersys

    I’ve added wppopups.hidePopup(42713, true); to jQuery("#geo-close").click(function() { but when I click “Visit US” on any page on the staging site, navigating to an additional page will also display the popup.

    My final JS is:

    <script>
    function redirect(){
        var loc = window.location;
        var pathname = loc.pathname;
        var AustralianSite = 'https://mandoestage.wpengine.com/en-au';
        var finalURL = AustralianSite + pathname;
        window.location.href = finalURL;
    }
    jQuery( document ).ready(function() {
        jQuery("#geo-close").click(function() {
             jQuery(".spu-container").hide();
             wppopups.hidePopup(42713, true); 
        });
    });
    </script>

    @ https://mandoestage.wpengine.com/wp-admin/admin.php?page=wppopups-builder&view=content&popup_id=42713

    Help appreciated.

    Plugin Author Damian

    (@timersys)

    Hi @srd75 ,

    1) What do you have in cookies ? https://wppopups.com/docs/how-to-configure-popup-closing-and-cookies/ Alse be sure you don’t have test mode enabled on the popup
    2) spu-container hide shouldn’t be needed as the closing function will close the container as well.

    Thread Starter SRD75

    (@srd75)

    Hi @timersys,

    Thanks, the cookie settings were set to 0. I set them to 30 and the problem was resolved.

    Funny that they are set to 0 by default! ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to set a cookie to remember the popup is closed’ is closed to new replies.