Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save glaubersilva/b67f60f6bf4fc0bafd49201f5cb3d95b to your computer and use it in GitHub Desktop.

Select an option

Save glaubersilva/b67f60f6bf4fc0bafd49201f5cb3d95b to your computer and use it in GitHub Desktop.
[Hustle] Prevents Exit Pop-Up On PayPal Checkout
<?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