Support

Home Forums Event Espresso Premium Leave Page Warning

Leave Page Warning

Posted: February 9, 2015 at 11:45 am


lhammond

February 9, 2015 at 11:45 am

We are getting the warning asking users to Leave Page or Stay on Page. Per this thread:
https://eventespresso.com/topic/confirm-navigation/
I understand that the submit button needs to have the class ‘allow-leave-page’ assigned to it. How can I do that for the PayPal gateway? We have customized the gateway templates for both PayPal and paying by personal check. The part that creates the form is called with

do_action('action_hook_espresso_display_offsite_payment_gateway', $data);

so I don’t know where to make the change. I did install the latest version of EE3, but we need the customizations in our gateway files. Can you help me figure out where to look to fix this?


Lorenzo Orlando Caum

  • Support Staff

February 9, 2015 at 12:58 pm

Hi, the PayPal standard payment gateway has that class:


Have you considered starting with a current version of the payment gateway and moving your customizations over?


Lorenzo


lhammond

February 9, 2015 at 1:18 pm

I was able to modify the submit button on my check submission form in check_payment_vars.php and that helped get rid of the warning when people submit that form to finalize their offline payment, however, once the Thank You page is displayed, clicking on any other link makes the warning pop up. I do have my Thank You page showing the PayPal gateway option, and the PayPal button does have the “allow-leave-page” class in it. I tried deleting the whole paypal form section in firebug but still got the warning after that. What causes that dialog to pop up?


lhammond

February 9, 2015 at 5:46 pm

I removed the files I had in uploads/gateways/ and found that I didn’t need my version of gateway_display.php, but without my version of gateway_paypal_display.php, the thank you page showed ONLY the payment overview block – the rest of the page all around it (my navigation, theme, everything!) was gone. I can’t find any references to that file name in any of my other files, so I’m not sure where it gets called or why exactly it is needed. Of course I can’t remember why I put it there, either! Is this a file that would be included somewhere by appending the gateway name? I’d like to see what is calling it so I know what to do with it.


lhammond

February 9, 2015 at 6:17 pm

Ok – I found the offending code. I was calling wp_enqueue_script for scripts/espresso_payment_page.js at the bottom of my gateway_paypal_display.php file. I don’t think that javascript is actually needed there, so I just removed it and voila! No more warning about leaving the page! Hopefully this information will be helpful to somebody else.


Lorenzo Orlando Caum

  • Support Staff

February 9, 2015 at 7:17 pm

Hi, I ran a search through the codebase for that file but did not find it. Is that a custom file that you have created?


Lorenzo


lhammond

February 9, 2015 at 10:14 pm

Apparently my gateway_paypal_display.php file is just a modified copy of gateway_display.php. I’m not sure how it was getting called, because I just propagated my changes to our live site and it’s not getting used there, so either I missed some customization I did when I was putting the new files up, or… maybe I’m just up way too late! 🙂 But I did have to comment out these lines from the bottom of gateway_display to make the Leave Page warning go away on my live site, and they are part of the template in 3.1.36.6.:

//wp_register_script( 'espresso_payment_page', EVENT_ESPRESSO_PLUGINFULLURL . 'scripts/espresso_payment_page.js', array( 'jquery' ), '1.0', TRUE );

//wp_enqueue_script( 'espresso_payment_page' );

Do you know the purpose of that javascript? I haven’t been able to go look at it yet, but maybe since you are more familiar with this code, you can tell me if it’s foolish to just comment those lines out?


Dean

February 10, 2015 at 5:18 am

The code controls both the leave page javascript and the show/hiding of the gateways. So if you are using more than one gateway they will be displayed in full.

So it doesn’t control anything important as such, though the lack of the page leave warning could cause an increase in over written registrations.

The support post ‘Leave Page Warning’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso