Posted: September 27, 2021 at 10:58 am
September 27, 2021 at 10:58 am Hi, We have an 8-class series which is taught throughout the year. It cycles continuously, and is taught in a manner so it doesn’t matter which class the agent takes first. One person may start on class 1 and end with class 8 four weeks later, another may start on class 5 and end on class 4 four weeks later. Because of that setup, each class has been setup as an individual event on our calendar. They all contain a portion of the same title (Ex – “BHU โ Class #1” or “BHU โ Class #2” that can be searched for, and all have the same category as well. Our goal is to have the students register for their first class – their start date, and then to have the system automatically register them for the following 7 classes based on their chosen start date. I’m using Zapier for many of our automations, but hesitate to use an “Add New Row” zap for MySQL due to the multiple tables involved, and the need for sequential row numbers in most of those tables. Do you have any suggestions for a better way to “find” the right 7 follow-up classes and then automate registering the student for them? Thanks, |
|
Hi Stephanie, I really don’t recommend you do this through Zapier to add rows manually, there’s a bunch of updates and relationships you need to set up for registrations in the database. There are hooks throughout EE for use cases like these so our recommended method would be to use one of those with our model system: https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System So you could hook into when a ticket is added to the cart and add additional registrations for the other events at that point. I’ve put together a simple example of doing the above using one of the hooks available in the checkout process here: https://gist.github.com/Pebblo/42a6755ac618e2f3b88c6b945c08ff53 That snippet uses the current ticket in the cart to pull the event, then finds out the category for that event and pulls the ‘next’ (base on datetime start date) 3 events from that category and adds the first ticket it finds from each of those events to the cart. Note that the above snippet is not an official feature of Event Espresso and should be considered untested. It is intended as a guide to creating your own version and won’t work for all use cases as is. I recommend you add a check within that function for it to only apply to the specific category you are intending this to be used on as right now it does the same for all events. |
|
Hi Tony, Thanks for the guidance. I’m in no way a programmer. How do I add the the filter to that code I need to add to the custom plugin? I’d want it to occur for only registrations involving category ID 61. In looking at what you’ve provided in other areas, am I just tacking something like this on?
|
|
If you only want it to happen on a specific category then where the snippet has this:
You can change it to something like this:
That should then only apply to the category with ID 61 |
|
Hi Tony, I added that code, but it doesn’t seem to be pulling the correct classes. Ex – I started a registration for Class # 2 on 10/13/21. It should have added class 3 on 10/19, class 4 on 10/20, class 5 on 10/26, class 6 on 10/27, class 7 on 11/2, class 8 on 11/3, and class 1 on 11/9. Instead, it added these: |
|
Can you recheck that screenshot? I think that might be the wrong screen. |
|
Whoops, sorry! Here you go: https://www.dropbox.com/s/zm79o2iz02lfehm/Screen%20Shot%202021-10-11%20at%203.23.30%20PM.png?dl=0 |
|
Hmm, strange. That could be from the Event query ordering by ID by default, try adding this line: Your line numbers will be slightly different due to the change above, but find that same location and add the above, any better? |
|
That seems to have worked, thanks so much for all your help Tony! |
|
You’re most welcome, I’m glad that worked. I’ve removed your screenshot from above just because its not related to anything here ๐ Any further issues just let me know. |
|
The support post ‘Auto-registering for additional 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.