Home Forums Event Espresso Premium Check if user logged in after clicking Add to Cart button

Check if user logged in after clicking Add to Cart button

Posted: January 4, 2015 at 7:26 pm

SBANE Webmaster

January 4, 2015 at 7:26 pm

WP 3.9.6, EE with MER 1.0.5.p, Members 1.9.8.p, Calendar 2.2.4.p and Business License

Happy New Year all!
We’re trying to resolve an issue with pricing discrepancies by adding a login-check to the Add to Cart button. This way, users will be prompted to login if they wish to get a lower price point for events, instead of logging in after adding the event to their cart – the latter action occasionally leads to the pricing not being consistent between the EE database and the info sent to payment gateways (e.g.,

We see the click event handler jQuery(‘body’).on(‘click’, ‘.ee_add_item_to_cart’,function(e){…} in the script espresso_cart_functions.js. Would this be a logical place to add the login check-in? Is there already an EE JS function for doing this that could be called?

Thanks in advance!
Erik Domingo
SBANE Webmaster


January 5, 2015 at 5:48 am


Yes espresso_cart_functions.js would be the logical place to add that sort of modification, but please note that that is a core file. Modifications to it will be over written on plugin update.

So, I would suggest creating a custom function based on espresso_load_jquery in espresso.php that would load a different version of the espresso_cart_functions.js file, one with your modifications (espresso_load_jquery is a pluggable function).

You would still need to check this file in relation to espresso_cart_functions.js every single update, in case of changes, but at least that way it won’t simply delete your changes.

In theory you could also use unbind() or off() to disable the click events via a different JavaScript file. I had some difficulty to get it to work, but I am not a master of jQuery.

SBANE Webmaster

January 6, 2015 at 8:14 am

Hi Dean,
Thanks for the clarification. We recognize the downside of modifying a core file, but since this is something the client wants, we’re going to have to move forward.

Just in case you missed the question, is there an EE check within a script for seeing if a user is checked in? I’ve seen a few approaches on Google for doing this, but if it’s already available in EE, it seems better to use that functionality.


  • Support Staff

January 6, 2015 at 9:22 am

Hi there,

Event Espresso doesn’t have JS function to check whether the user is logged in. However, WP has a PHP function that’s built in:

The support post ‘Check if user logged in after clicking Add to Cart button’ 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.

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3

Documentation for Event Espresso 4

Status: closed

Updated by  Josh 5 years, 1 month ago ago

Topic Tags



This topic is: not resolved
Do NOT follow this link or you will be banned from the site!