Forked from wpmudev-sls/hustle-prevents-exit-popup-on-paypal-checkout.php
Created
June 4, 2022 15:03
-
-
Save glaubersilva/b67f60f6bf4fc0bafd49201f5cb3d95b to your computer and use it in GitHub Desktop.
[Hustle] Prevents Exit Pop-Up On PayPal Checkout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Plugin Name: [Hustle] Prevents Exit Pop-Up On PayPal Checkout | |
| * Plugin URI: https://wpmudev.com/ | |
| * Description: Useful for not triggering Pop-Ups giving discounts if the member is already on the final payment stage. | |
| * Author: Glauber Silva @ WPMUDEV | |
| * Author URI: https://wpmudev.com/ | |
| * Task: SLS-3370 | |
| * License: GPLv2 or later | |
| * | |
| * @package Hustle_Prevents_Exit_Pop-Up_On_PayPal_Checkout | |
| */ | |
| defined( 'ABSPATH' ) || exit; | |
| /** | |
| * This snippet will prevent the exit pop-ups to be triggered only if the | |
| * PayPal modal overlay element is visible on the page - it usually gets | |
| * visible when the user clicks on the PayPal button. | |
| * | |
| * However, the "overlay modal" can take some seconds until be displayed | |
| * and in the meantime, the user can move the mouse and trigger the pop-up. | |
| * | |
| * So, a possible workaround would be also to block the exit pop-up if there | |
| * are any PayPal buttons being displayed on the page, but it will also prevent | |
| * the pop-up to be displayed even if the user hasn't yet clicked in any button. | |
| * | |
| * Thus, if you wish to block the exit pop-up if any PayPal button is visible | |
| * on the page, just to uncomment the commented line ( removing the two slashes | |
| * in front of it) on the code block below... | |
| */ | |
| add_action('wp_footer', function() { | |
| ?> | |
| <script type="text/javascript"> | |
| (function($) { | |
| $( document ).ready( function() { | |
| $(document).on('hustle:module:displayed', function() { | |
| if ( $( '.paypal-checkout-sandbox' ).length ) $('.hustle-ui.hustle-popup.hustle-show').css("display", "none"); | |
| //if ( $( '.paypal-buttons' ).length ) $('.hustle-ui.hustle-popup.hustle-show').css("display", "none"); | |
| }); | |
| }); | |
| })(jQuery); | |
| </script> | |
| <?php | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment