Posted: September 9, 2013 at 10:20 pm
|
Hi, I realize, as of 4 months ago, the plugin does NOT support checking for conflicting events (https://eventespresso.com/topic/disallow-conflicting-events/). I was wondering if that status of that feature has been changed. I’m developing a site for a client, and this is a must-have feature. If it’s not supported, does anybody know how to work around it? Please let me know, as I’m kind of on a time crunch. I’ll forever be in your debt! Thanks! |
|
Hi Tam, The status of that feature hasn’t changed. It is still a possibility to be included in the next major release (4.X) but nothing has been decided on its fate. As for a workaround, the best I can think of would be javascript. Add a script that checks the event titles or event id’s in the cart and if two conflicting events are in there, display an error message. If you do not know javascript, you may wish to contact one of our recommended developers https://eventespresso.com/developers/event-espresso-pros/ |
|
Thanks Dean. I noticed that in the previously discussed thread (https://eventespresso.com/topic/disallow-conflicting-events/), you posted a link to a PHP snippet that would be a workaround for this problem if the user is logged in. Do you think I can somehow tweak it to make it work? If so, where do I start? Thanks! |
|
I guess it’s worth noting that I may have as many as 12 events within a week that I need to check for conflict, so it may be (12 choose 2 =) 66 cases for worst case scenario ๐ |
|
Yes, you could tweak Dean’s code to check for timing conflicts (right now it checks if the user has already signed up for the event they are attempting to sign up for), but the user is going to need to be logged in for it to work. Also, since it is designed to be inserted into the registration form page, where the event being signed up for may have multiple dates and times, it would make it considerably easier to write such a check if the events are for a single day, and have a single timeslot. Let us know if your events conform to that restriction. Thanks. |
|
Unfortunately, the events may spread over a few days. For example, Event A would be Mon-Fri, 8-5, and then Event B would be Tue-Fri, 8-12, and Event C would be Tue-Thur 1-5. This means that both B and C would conflict with A, but not among themselves. I don’t mind if a user adds conflicting events to their cart, I simply need the system to throw an error at some point before checkout – ANY error at all. I was thinking somewhere in the shopping_cart.php file. I see that a list of results are pulled from the DB. If I could just intervene somewhere in that file, that’d be great. Please help ๐ |
|
It does make it a bit more complex. Where Dean’s code pulls out a list of events which the user has signed up for before, you then need to take that data and form a list of days and times: $pot_conflicts['eventA']['09-09-2013']['start_time']="08:00 AM"; $pot_conflicts['eventA']['09-09-2013']['end_time']="05:00 PM"; etc, generating an array. You then need to do the same for the events that are in the cart: $cart_events['eventB']['10-09-2013']['start_time']="08:00 AM"; $cart_events['eventB']['10-09-2013']['end_time']="12:00 PM"; Then nest the looping of both arrays: foreach($cart_events as $cart_date){ foreach($pot_conflicts as $pot_conflict){ foreach($cart_date as $date1=>$time1){ if(!empty($pot_conflict[$date1])){ if((strtotime($pot_conflict[$date1]['start_time'])>strtotime($time1['end_time'])) || (strtotime($pot_conflict[$date1]['end_time'])<strtotime($time1['start_time']))) { vast_explosion(); I would love to help, but I can’t take the time to write, test, and debug a complete piece of custom code in the forums when it means that other people will not get their questions answered. If you need someone to develop a complete solution for you, I would suggest contacting one of our recommended developers: https://eventespresso.com/developers/event-espresso-pros/ |
|
I understand Sidney. Your code snippet helped me steer into the right direction. It’ll try to get a crack at this, and report back later. Thanks! |
|
Thanks Tam, please keep us updated. |
The support post ‘Prevent users from signing up with conflicting 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.