Posted: August 30, 2015 at 11:32 pm
|
I am testing the upgrade to EE4 and trying to replicate the information we presented using EE3. I want to display different info if tickets sales are open, closed or upcoming. This is EE3 version: http://test.southgatemelbourne.com.au/southgate-cinema/ If you hover on the cinema listing, the screening and booking information is displayed. How do I get the start and end dates/times for ticket sales in EE4 in order to do this? |
Hi Jo, Event Espresso 4 has a status option banner (e.g. upcoming) that can be turned on through Event Espresso –> Events –> Templates. However, I see you are presenting that information differently. There is a template tag available that can be used to check the status of an event (https://eventespresso.com/wiki/ee4-themes-templates/): espresso_event_status() — |
|
|
Hi Lorenzo Thanks for the suggestion, but this doesn’t really give me the info that users want. We need to be able to tell users when bookings go on sale or if they are already closed. The cinema screenings usually book out within minutes so the earlier we can present this info the better (ie before clicking through to a single event). I was hoping I could at least query the database directly for the start/end dates & times. I’ve looked through all the tables and can’t actually find this data. Can you assist? thanks |
Hi Jade, So right now with EE3 are you using the ‘Registration start date’ for those details? With EE4 how are you listing the shows currently? I’m assuming your doing a custom query and have post objects to loop over but are you using the EE Models to pull in the info? http://developer.eventespresso.com/docs/model-querying/ You mention the event start date (which would be the datetime dates) which can be used to output the Event Start and End dates/times, when using the models to get the info you’d use something like: $datetime->start_date_and_time(); $datetime->end_date_and_time(); However I don’t think you need those details, but rather the ticket ‘Sale Starts’ date and the ticket status. The start doesn’t matter if its sold out you just need to show its now sold out using either the ticket status or event status, so far does that make sense? |
|
|
Hi Tony, Yep we were using a bunch of meta fields for presenting the data with EE3 Yes that’s right with EE4 we’re doing a custom query — No we’re not using these models. I haven’t seen this documentation before. Thank you, I’ll have a read over this. And yes, I meant the start/end dates for ticket sales (not the event itself). Thanks! |
|
Hi Tony, I’ve started working with the EE Models now. I’m not sure if there’s a more efficient way of doing it, but I’ve managed to get all the pieces of data I need to work with…
Thanks! |
Awesome! I’m glad the models worked for you. I have a couple of pointers for your code, first one is a quick one: current_time() is missing its 1st aregument for type, use – current_time(‘timestamp’, true) Your also repeating yourself a few times and pulling information that you can get from the models. Try this: $events = EEM_Event::instance()->get_all( array( array( 'Term_Taxonomy.Term.term_id' => 16, 'Datetime.DTT_EVT_start' => array( '>', current_time('timestamp', true))), 'order_by' => array( 'Datetime.DTT_EVT_start' => 'ASC' ) ) ); foreach( $events as $event ) { echo $event->name()." Notice the debugging sections I currently have commented out? That’s using Kint (which is awesome!) you might want to install Kint using something like: https://wordpress.org/plugins/kint-php-debugger/ Then un-comment out one of those lines (or all of them) and view the kind of information you can pull with the models. For example on the ticket object you have the start_date() method which does all the work for you, there is 160 different methods on the ticket alone, so you’ll usually find a method to get what you want – http://take.ms/LyChf I removed the ID variables and just used the object directly, and also added in some instance checks to make sure we did not try to run methods if nothing is returned. There’s nothing wrong with the code you posted btw! It works just fine (assuming you always have one datetime and ticket) but the above just does more of the work for you π
|
|
Hi Jade, One of our developers mentioned that there is a problem with the above query, I’ve update my example but just wanted to make you aware of it. The timestamp passed to the query must be UTC+0 (GMT) or ‘normal’ unix timestamps, this means you can’t use just current_time(‘timestamp’) as that will include the timezone offset that WP adds. So when passing a timestamp simply use: current_time(‘timestamp’, true) Which tells the function to pass back a GMT timestamp. (Note the developer docs will be updated to reflect this to) |
|
|
Really appreciate your pointers Tony! This is much more efficient π I have the page displaying now as it was before in EE3. Very happy. http://www.southgatemelbourne.com.au/southgate-cinema/ Thanks for your help. |
You’re most welcome, Jade. I like what your doing there btw, it’s a nice implementation of the ‘events’ π |
|
The support post ‘EE3 to EE4 upgrade, replicate tickets on sale info’ 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.