Posted: September 15, 2014 at 7:25 am
|
I am currently running EE4. I am sure this has been answered before but I can not find a tread regarding only displaying an URL to purchase tickets if the event has available tickets. I am trying to add a button to my custom event list page. Can someone share the php code with me? Thanks, |
When you say custom event list is will depend on how you are doing this. The event objects have the is_sold_out() method which will return true if the event is sold out, and false otherwise. So you can check each event using something like if ( $event->is_sold_out() || $event->is_sold_out(TRUE) ) { //code for when an event is sold out. } else { //code when event is NOT sold out. } The ‘TRUE’ parameter forces a check on all the datetimes to get their current values and checks if they are sold out. Without this parameter you are relying on the static variable within the object. However, again this depends on what code you are using to build your custom event list. |
|
|
I am sorry. yes I should have show how I was calling the events. Here it is NULL, 'limit' => 100, 'css_class' => NULL, 'show_expired' => FALSE, 'month' => NULL, 'category_slug' => 'maestro-series-1409680514', 'order_by' => 'start_date', 'sort' => 'ASC' ); // run the query global $wp_query; $wp_query = new EE_Event_List_Query( $atts ); espresso_get_template_part( 'content', 'espresso_events-venues' ); $x = new EE_Event_List_Query(); if (have_posts()) : while (have_posts()) : the_post(); ?>
|
|
September 15, 2014 at 10:49 am So inside your loop, you can uncomment the var_dump($post) to take a look and make sure that you are retrieving EE_Event objects. Then you can make that method call on them to test to see if they are sold out, like Tony said: if ( $post->is_sold_out() || $post->is_sold_out(TRUE) ) { |
|
September 15, 2014 at 11:30 am Thanks. This is what I decided to add to change my child theme code. <?php $espresso_event_tickets_available = espresso_event_tickets_available(); ?> It has been working out fine so far today. |
September 15, 2014 at 12:34 pm Thanks for the update. If this support request has been solved, then please change the status to resolved. — |
|
The support post ‘Show link if event has available tickets’ 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.