Hello,
When a user clicks the “Add to Event Cart” button, the text changes to “View Event Cart”. They can then click the same button again to be redirected to the event cart page.
Is there a hook/filter available to disable that secondary-click action (while maintaining the change in text from the first click that indicates that they’ve registered for the event)?
I have multiple ticket selectors on one page and I’m using the mini-cart shortcode to provide links to their cart, etc. I don’t want users using the ticket selector buttons to jump ahead to checkout.
I tried using a Javascript onClick() function to disable the button after the first click. However, if an error message is displayed (Event Full, etc.), the onClick function is still triggered, so the button becomes inactive before the user can actually register.
Appreciate any other options or solutions that might exist.
The wp_enqueue_scripts action hook along with the wp_add_inline_script()
function is well suited for this type of thing. Here’s an example you can try:
Out of curiosity: is there a benefit to adding this as PHP code & hook in a functions plugin vs just adding the JQuery parts of the code directly to my page?
PS: learning about .ajaxComplete() has changed my life 🙂
There’s a couple of benefits, the code within the plugin is reusable and will automatically be output to any location on your site that outputs the button (because it is hooking into the MER scripts so when are added, so is Josh’s code).
If you decide to change something within the code it’s easier to manage in a single locaition rather than multiple template files where the script may have been called etc.
Viewing 3 reply threads
The support post ‘Remove 2nd Click "View Event Cart" action – but keep text change’ 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.