Support

Home Forums Event Espresso Premium Delete Required for "0" Events

Delete Required for "0" Events

Posted: February 14, 2017 at 8:36 am

Viewing 5 reply threads


Chester Bowl

February 14, 2017 at 8:36 am

Hi there. I’m auto-loading events into the cart using [ESPRESSO_CART_LINK event_id=”5-8-9″ anchor=’CLICK HERE’ direct_to_cart=1 moving_to_cart=’Loading Registration …’]

The list of events that generates in the cart allows you to specify “0” as the number of each one if you want, but when you click on the registration button it throws up an error that says you must also DELETE those “0” events. I’m actually auto-loading some 40 events, and going through to delete half of those is a chore. Is there any way to disable the error?

And if I disable it, will that mess things up on the back end? For example, will there be a bunch of “0” events appearing in the attendee lists on the back end, or something?

Thanks!


Tony

  • Support Staff

February 15, 2017 at 12:01 pm

Hi there,

Currently its not possible to disable that error, the events with 0 tickets would need to be manually removed from the cart for the registration to continue.

Another option would be to use the Event Table template to output a list of events which allows your users to select the events they actually want to add and then continue to the cart rather than adding them all and removing the events they don’t want.

Would that work?

This is the events table:

https://eventespresso.com/wiki/events-table-view-template-add-on/

It include a Register and ‘Add to cart’ link for each event shown.


Chester Bowl

February 15, 2017 at 6:16 pm

I’m thinking about implementing an onclick function on the submit button that will delete the “0” items automatically. I think that will bypass the error. Thanks for the suggestion, though! 🙂


Tony

  • Support Staff

February 16, 2017 at 10:36 am

How comfortable are you with PHP?

I did a little more digging into this and the function that controls the output of that page is pluggable which basically means you can override the original function with your own custom version.

So what you can do is copy the event_espresso_load_checkout_page() function to a custom_functions.php file placed in /wp-content/uploads/espresso/ then modify the function there to remove the events from the session rather than display an error message.

We can’t provide support for customizations but if you take a look at the function called when the delete icon is click you should be able to figure out what you need to do based on that.


Chester Bowl

February 20, 2017 at 2:29 pm

Hi there. If I delete the following code, it seems to work the way that I want, WITHOUT even adding code to actually delete the “0” items automatically.

Original behavior: Throws up an error for each item with “0” attendees in the cart.

Modified behavior: It goes straight to the payment page with no error. Furthermore, there are no “0” events listed in the payment overview there. And if I check the back end after registering, there are no weird “0” events listed as attendees or anything.

So, my question is, would I be messing up anything on the back end by just removing the error code below?

wp-content/plugins/event-espresso/includes/functions/cart.php

								//If they have selected more than allowed max group registration
								//display an error instead of the continue button
								if ($total_attendees_per_event > $attendee_limit || $total_attendees_per_event == 0) {
									$attendee_overflow = true;
									$show_checkout_button = false;
								}
							}

							if ($attendee_overflow) {

								$err .= "<div class='event_espresso_error'><p><em>" . __('Attention', 'event_espresso') . "</em><br />";
								$err .= sprintf(__("For %s, please make sure to select at least one attendee or delete it from your cart.", 'event_espresso'), stripslashes($r->event_name), $attendee_limit);
								$err .= '<span class="'.espresso_template_css_class('remove_cart_item','remove-cart-item', false).'"><img class="'.espresso_template_css_class('ee_delete_item_from_cart','ee_delete_item_from_cart', false).'" id="cart_link_' . $event_id . '" alt="Remove this item from your cart" src="' . EVENT_ESPRESSO_PLUGINFULLURL . 'images/icons/remove.gif" /></span> ';
								$err .= "</p></div>";
							}


Tony

  • Support Staff

February 21, 2017 at 3:48 am

Did you follow the steps I posted above to override that function? Modifying the core function within EE is not something we can support.

So, my question is, would I be messing up anything on the back end by just removing the error code below?

It shouldn’t, but its not something we support so you would need to fully test this to confirm as your modifying the code. Although EE is not saving those additional events they are within the session during the checkout so the potential to cause issues is still there.

I’d recommend removing them from the session rather than just removing that code.

Something like:

unset( $_SESSION['espresso_session']['events_in_session'][$event_id] );
$show_checkout_button = true;
Viewing 5 reply threads

The support post ‘Delete Required for "0" Events’ 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