I know its best to copy the Single-event.php to my child theme and then copy these lines in:
//In your single-event.php template:
$remaining = eo_get_remaining_tickets_count( get_the_ID() );
if( $remaining > 1 ){
printf( ‘Hurry, only %d tickets remaining’, $remaining );
}elseif( $remaining == 1 ){
echo ‘Only one ticket remaining!’;
}else{
echo ‘Sorry, there are not tickets available’;
}
But when i do that, my theme template on the single event page is messed-up a bit?
No padding on the sides for instance…
How to resolve this?
And futhermore: placement of the text.. How can i adjust this? I would like the text to be just beneath the ticketsbox, of above..? Now its all the way down.

Willem Wiers
It’s probably easiest to not have single-event.php
but instead copy the event-meta-event-single.php
partial template. In that case, the single.php
template is used, but the partial template inserted just before the content. This usually makes for better compatibility.
If you want a single-event.php
template because, for instance, the theme includes things in the single.php
template that you do not want for events, then you should copy the single.php
from the theme and edit it accordingly (using the example single-event.php
as a guide) – that will help ensure that the template fits with your theme.

Stephen Harris
Hi Stephen,
Thanx for your reply. That worked so i do have a function “tickets available” at this moment!
But….. i’m not completely satisfied, the tickets available should better be at the ticketpicker (would be nice to have the availability in the same box as the ticket discription..?)
And futhermore, now i have an event with two dates, so therefore two tickets…. the availability can not see ofcourse which of the two dates is full… any solution for this?

Willem Wiers
Hi Willem,
If you have multiple dates then you first need select a date. If a ticket is sold out, then it will indicate that once you select the date.
If a date’s tickets are all sold-out, it will not be selectable in the datepicker.
The code above for displaying remaining tickets is only really useful for when you have just one date, as otherwise you need to provide the second argument (occurrence ID) to eo_get_remaining_tickets_count()
– but that will depend on the date the user selects, so you would likely need to be make an ajax call to update that value.

Stephen Harris
Hi Stephen,
Oke, thats a bit to difficult for me i think 🙂 For now we’ll use it as it is i think..
But there is one other thing…
With the code i added (below) with events where there are no tickets, just an annoucement for instance this says ‘Sorry, there are not tickets available’;
Can i add a line of code so that this is not showing on an event without tickets?
//In your single-event.php template:
$remaining = eo_get_remaining_tickets_count( get_the_ID() );
if( $remaining > 1 ){
printf( ‘Hurry, only %d tickets remaining’, $remaining );
}elseif( $remaining == 1 ){
echo ‘Only one ticket remaining!’;
}else{
echo ‘Sorry, there are not tickets available’;
}
Kind regards.
Willem

Willem Wiers
You can use eo_get_event_tickets
(http://codex.wp-event-organiser.com/function-eo_get_event_tickets.html) – if it returns an empty array then the event does not have any tickets.
In your case you should pass the returned value of get_the_ID()
as the first argument.

Stephen Harris