Popup when closing tab if any product is in cart

frizzel

Well-known member
Trusted Uploader
Jun 13, 2019
485
253
63
Wherever my imagination takes me
Wonder how he'll just share a picture and expect a newbie or person needing help to write it on their own. If they knew how to go about it, they wouldn't ask for help.
I did NOT just share a picture, I shared some code first, already back in March by the way. But since the site does not allow javascript tags (which is understandable) I shared the full code as a picture.

However, apparently some people are too dumb to understand and implement.

@ngepetlo you think any code is unique on the internet? This question was about a pop-up in Elementor page builder, which is not covered in the code you're linking to. But I suppose you missed that part.

I just tried to help. I offered my help many times before, but I've noticed the quality of Babiato members clearly going down recently, so I suppose I'll refrain from that and simply resort to leeching.

Bye.
 
  • Like
Reactions: KoolPal

Saint Gabriel

Well-known member
Jan 3, 2020
2,998
3,049
113
I did NOT just share a picture, I shared some code first, already back in March by the way. But since the site does not allow javascript tags (which is understandable) I shared the full code as a picture.

However, apparently some people are too dumb to understand and implement.

@ngepetlo you think any code is unique on the internet? This question was about a pop-up in Elementor page builder, which is not covered in the code you're linking to. But I suppose you missed that part.

I just tried to help. I offered my help many times before, but I've noticed the quality of Babiato members clearly going down recently, so I suppose I'll refrain from that and simply resort to leeching.

Bye.
Ciao.
 

WebTrend

New member
Feb 2, 2021
15
2
3
I did NOT just share a picture, I shared some code first, already back in March by the way. But since the site does not allow javascript tags (which is understandable) I shared the full code as a picture.

However, apparently some people are too dumb to understand and implement.

@ngepetlo you think any code is unique on the internet? This question was about a pop-up in Elementor page builder, which is not covered in the code you're linking to. But I suppose you missed that part.

I just tried to help. I offered my help many times before, but I've noticed the quality of Babiato members clearly going down recently, so I suppose I'll refrain from that and simply resort to leeching.

Bye.

Thank you so much and I appreciate your help.
I'm using woodmart theme and adding to cart is done with axaj. I can't disable that.

Then popup will be shown only after page refresh.

Do you know some solution?
 
Last edited:

frizzel

Well-known member
Trusted Uploader
Jun 13, 2019
485
253
63
Wherever my imagination takes me
In that case only javascript will do the trick when triggered if something is added to the cart. Be sure to now place 'var popupcounter' before the call, otherwise it's every time reset to 0. The javascript code:

JavaScript:
jQuery(function($){
    var mouseX = 0;
    var mouseY = 0;
    var popupCounter = 0;
        $('body').on( 'added_to_cart', function(){
                document.addEventListener("mousemove", function(e) {
                    mouseX = e.clientX;
                    mouseY = e.clientY;
                });
                $(document).mouseleave(function () {
                    if (mouseY < 50) {
                        if (popupCounter < 1) {               
                            elementorFrontend.documentsManager.documents[130].showModal();
                        }
                        popupCounter ++;
                    }
                });
        });
});

Remember the number between brackets [130] is the ID of your Elementor Popup.
 
Last edited:

WebTrend

New member
Feb 2, 2021
15
2
3
Is it enough to past code here (inside woodmart settings) ?

1621970440475.png


One more problem is that popup opens after footer :(
I've checked options od popup and everything is ok.

1621971576924.png
 
Last edited:

frizzel

Well-known member
Trusted Uploader
Jun 13, 2019
485
253
63
Wherever my imagination takes me
I don't understand why the codes revert to one line, I use new lines and indents, but every time I see it reverting to one line, @Tomz : why is that happening?

Anyway, putting it in the woodmart settings should work, but you can also try to put it in functions.php like so:

PHP:
<?php

add_action( 'wp_footer', function () { ?>

/* put the opening script tag here */

        jQuery(function($){
            var mouseX = 0;
            var mouseY = 0;
            var popupCounter = 0;
                $('body').on( 'added_to_cart', function(){
                        document.addEventListener('mousemove', function(e) {
                            mouseX = e.clientX;
                            mouseY = e.clientY;
                        });
                        $(document).mouseleave(function () {
                            if (mouseY < 50) {
                                if (popupCounter < 1) {                
                                    elementorFrontend.documentsManager.documents[130].showModal();
                                }
                                popupCounter ++;
                            }
                        });
                });
        });

/* put the closing script tag here */

<?php } );

Don't forget to remove your code in woodmart settings and change the lines where I indicated opening and closing script tags should come.

If it then still renders after the footer, then there's something else wrong as in my set-up it works normal.
 

About us

  • Our community has been around for many years and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. We are working every day to make sure our community is one of the best.

Quick Navigation

User Menu