Posted: July 7, 2021 at 1:40 pm
Hi there, Im doing a Woocommerce integration and need to introspect ticket information when the wp post associated with the EE_Event is created or updated. Im using the standard ‘save_post_espresso_events’ hook and getting an instance of the EE_Event with ‘$theEvent = EEM_Event::instance()->get_one_by_ID($post_id);’, which returns an event with basic info like name and description in it; However, $theEvent->tickets() returns an empty array. Its only after I resave/update the post the mentioned code returns a populated array of EE_Ticket items. Perhaps Im acquiring the EE_Event object incorrectly? Or the ticket info doesn’t get saved until later? Is there a different hook I should be using that gets called after the ticket info is saved/available? – Morgan |
|
Hi Morgan, Tbh, I’m surprised After a little digging we have another option for you:
The above callbacks are used whenever an EE event is created/updated and the $event object is passed directly so no need to for |
|
Thank you for the code; Unfortunately Im getting the same results! Here is my code (organized in an SS_EEWC_BRIDGE class) //In the constructor //Then….. static public function insertUpdateEventCallback($callbacks){ static public function ee_event_updated_callback($ee_event){ Steps: On the console I get: 2) Hit the publish button again (which now is labeled ‘Update’) Console output: I should also note that neither the ‘trashed_post’ nor ‘wp_trash_post’ hooks fire when I delete an EE Event! – Morgan |
|
I should note, with my original code, I tried setting the priority number in the add_action() call to something really high…10000… and then 100000; That didn’t work either. |
|
Hmm, strange. I tested my snippet before I replied above and it works for me (just confirmed again to check), as long as you have a priority of 11 or more it should work on both event publish an update. May I ask, how are you initializing the class above? I’ll try using the same method. Creating a new event, empty debug log: Hitting publish: Sidenote – whilst |
|
So frustrating… I tried turning off all the plugins.. rewrote it without the class wrapper… rewrote it again… once more for good measure, lol. I finally figured it out! So, I never actually tried ‘save_post’; I went straight to using ‘save_post_espresso_events’. It appears the tickets are available right away with ‘save_post’, but not with ‘save_post_espresso_events’! Thanks for the quick responses and trying it yourself in code. Much appreciated. – Morgan |
|
Hmm, so, first… nice find! I’m not sure why the However, I checked into Also, a polite reminder (although I’m sure you already are) to make sure you check the post type when using |
|
The support post ‘Introspecting ticket information upon event creation’ 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.