Support

Home Forums Event Espresso Premium Show all events with places remaining

Show all events with places remaining

Posted: March 29, 2017 at 4:36 am

Viewing 12 reply threads


nmaddock

March 29, 2017 at 4:36 am

Hi,

I guess this is three questions!

For Event Admin –

1. Is there a way in the back-end for Event Admins to see a list of events that shows how many places are left for each date/time instance?
This would be really useful to have.

2. If not, is it possible to do something on the front-end to show this, so Admin can go to one page that shows all future events with places remaining?

(I did try putting the [ESPRESSO_EVENT_ATTENDEES] shortcode on a new page to see what that would show, but it doesn’t show anything – even though we have lots of upcoming events.)

For end users –

3. Is there any code I can add which will show on every event page, how many places are remaining for each date/time instance (not tickets left)

Can you help please?
Thanks


nmaddock

March 29, 2017 at 7:53 am

Hi,

re point 3 – I\d ideally like to show this information before the ticket selector display but after the main event content.

Thanks!


nmaddock

March 29, 2017 at 7:58 am

Hi,

again regarding point 3 – I also tried out the code below which I found (supposed to be used as a shortcode – but added it to functions.php)

// print the remaining tickets left for each datetime

function my_print_tickets_left_after_selector($atts) {
global $wpdb;

$EVT_ID = get_the_ID();

//display a title
$x = ‘<h4>Remaining spaces</h4>’;
$x .= ‘<ul style=”margin-left:0;”>’;

$sql = “SELECT * “;
$sql .= “FROM {$wpdb->prefix}esp_datetime “;
$sql .= “WHERE {$wpdb->prefix}esp_datetime.EVT_ID = %d”;

$datetimes = $wpdb->get_results( $wpdb->prepare( $sql, $EVT_ID ));

$dt_frmt = get_option(‘date_format’);

//echo “

" . print_r($datetimes,1) . "

“;

foreach($datetimes as $datetime){
//display as a list
$x .= “

  • “;
    //if datetime name shown, display
    $name = !empty($datetime->DTT_name) ? ($datetime->DTT_name) . ‘: ‘ : date($dt_frmt, strtotime($datetime->DTT_EVT_start) ) . ‘: ‘;
    $x .= $name;

    $limit = $datetime->DTT_reg_limit;
    $sold = $datetime->DTT_sold;
    $remainderp = $limit – $sold;
    $remain = $limit == -1 ? ” : $remainderp;
    if ( $limit == $sold ) :
    $x .= ‘Sold Out‘;
    else :
    $x .= $remain;
    endif;
    $x .= “

  • “;
    }
    $x .= ‘‘;

    return $x;

    }
    add_action( ‘AHEE__ticket_selector_chart__template__after_ticket_selector’, ‘my_print_tickets_left_after_selector’, 10, 2 );

    Nothing is output at all.
    I even commented most of it out so it should have just displayed the h4, but nothing.

    I also have the wait-list workaround using that same add_action statement… add_action( ‘AHEE__ticket_selector_chart__template__after_ticket_selector’, ‘ee_special_sold_out_message’, 10, 2 );

    Thanks


    Tony

    • Support Staff

    March 30, 2017 at 4:42 am

    Hi there,

    1. Is there a way in the back-end for Event Admins to see a list of events that shows how many places are left for each date/time instance?
    This would be really useful to have.

    Wouldn’t they just look within the event and view the datetimes?

    2. If not, is it possible to do something on the front-end to show this, so Admin can go to one page that shows all future events with places remaining?

    We don’t have anything that will output this currently but yes its possible with custom development.

    (I did try putting the [ESPRESSO_EVENT_ATTENDEES] shortcode on a new page to see what that would show, but it doesn’t show anything – even though we have lots of upcoming events.)

    ESPRESSO_EVENT_ATTENDEES outputs the attendee details for an event, not spaces available etc. If you add it to a random page it will try to use the next upcoming event but if it can’t find the event, it will output nothing.

    3. Is there any code I can add which will show on every event page, how many places are remaining for each date/time instance (not tickets left)

    There’s a few issues with the code you’ve posted, as you’ve changed how the code will be used from a shortcode into an action yet the code returns the value as expected to be used in a shortcode which as you’ve found outputs nothing to the page.

    Have you confirmed that the shortcode version outputs the details you need when you use the shortcode?


    Tony

    • Support Staff

    March 30, 2017 at 4:43 am

    I also have the wait-list workaround using that same add_action statement… add_action( ‘AHEE__ticket_selector_chart__template__after_ticket_selector’, ‘ee_special_sold_out_message’, 10, 2 );

    Is that working as expected?


    nmaddock

    March 30, 2017 at 5:15 am

    Hi Tony,

    thanks for the reply.

    1. but they’d have to do that for each event; hence my question! 🙂

    To save them time, they’d ideally just run down a view & quickly check.
    Any thoughts on this?

    2. Ah ok. Any pointers on how we might achieve this?

    3. I’ve not used the shortcode as I presume I’d need to change a template to do that? We’ve not touched single events at all and don’t really want to get into changing templates this late into development.

    Can you give any hints as to what I’d need to change to get it working as an action please?

    Yes, the wait-list workaround works a treat! 🙂

    Thanks.


    Tony

    • Support Staff

    March 30, 2017 at 9:56 am

    1. but they’d have to do that for each event; hence my question!

    It really wasn’t clear on what your looking for, hence my answer (which was really a question again) 🙂

    Currently we don’t have an option for that, its possible to include but would require some custom development.

    2. Ah ok. Any pointers on how we might achieve this?

    I can give you an overview of how I would do this.

    You can use this as a base: https://gist.github.com/joshfeck/6e33532c37a123bbf532

    Pull the events that are upcoming or active (possibly exclude sold out events?)

    Loop through each event and pull the datetimes, then on each datetime use something like:

    $datetime->spaces_remaining();

    Which returns the spaces available based on {datetime limit} – {sold and reserved tickets}

    Or

    $datetime->total_tickets_available_at_this_datetime();

    Which returns the number of spaces available on the datetime taking into consideration all tickets available on the datetime.

    3. I’ve not used the shortcode as I presume I’d need to change a template to do that? We’ve not touched single events at all and don’t really want to get into changing templates this late into development.

    To confirm if the shortcode version actually output what your expecting? No you’d just use the shortcode on a page and pass the event id to the shortcode.

    Can you give any hints as to what I’d need to change to get it working as an action please?

    You don’t return anything with an action, you need to echo the output.

    However take a look at the hook you are using, you’ll find it’s passed the $EVT_ID and $event (which is the EE_Event object):

    do_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event );

    That means you can use our models and avoid most of the hoop jumping the above code is doing, for example:

    https://gist.github.com/Pebblo/3d019689d6c51a302eb95bbd3174b91e

    The above is more of a base that you’ll want to modify to suit your needs.

    If you haven’t already I’d recommend taking a look at how out models system works here:

    https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System

    That help?


    nmaddock

    March 31, 2017 at 2:34 am

    Thanks Tony, I appreciate your help.
    I’ll see what I can do with points 2 & 3!


    nmaddock

    March 31, 2017 at 2:39 am

    Hi again,

    is there a doc that will show me what ‘hook’ (I think it’s called) I can use to position the places remaining action just before the ticket selector and after the main event content?

    Thanks


    Tony

    • Support Staff

    March 31, 2017 at 3:50 am

    Have you altered the default order of the event details?

    The ticket selector would normally show before the event details, so are you wanting to include the remaining spaces twice?

    Or have you moved the ticket selector after the content and now want it displayed above that?

    There’s a lot of different options within EE which can effect the output and how you add additional details, so the more details you provide the better we can help.

    There is another hook fired just before the ticket selector:

    do_action( 'AHEE__ticket_selector_chart__template__before_ticket_selector', $event );

    Note that only passes the $event, so the example code I provided needs to be changed as its expecting $EVT_ID


    nmaddock

    March 31, 2017 at 4:16 am

    Thanks Tony.

    The order of elements displayed for a single event has been changed using Events > Templates > custom display order, as follows –

    Event Description
    Dates and Times
    Ticket Selector
    Venue Information (not used)

    So what would I use to place this info above ticket selector based on our custom order?

    I’ll try the one you provided, do I just change $EVT_ID to $event in the code?

    I’ve done some testing with the base code you kindly provided and have noticed three things…

    1. The first date/time availability shown always has places available – 2 for some reason. e.g. 10 places available, 8 shown.
    The other date/time places are shown correctly.

    2. Date/times in the past are still shown, even if tickets are no longer on sale. (none sold)

    3. The sequence of date/times shown doesn’t take year into account; e.g. 17-18 March 2018 is shown before 18-19 March 2017.

    I’d really appreciate your thoughts on these 3 points?

    Thank you.


    Tony

    • Support Staff

    March 31, 2017 at 9:55 am

    So what would I use to place this info above ticket selector based on our custom order?

    You can use the hook I mentioned above.

    I’ll try the one you provided, do I just change $EVT_ID to $event in the code?

    No there’s a few changes needed, the function should only be passed $event, and the hook needs the 2 removed from the filter call as that is what tells the function how many parameters are passed.

    1. The first date/time availability shown always has places available – 2 for some reason. e.g. 10 places available, 8 shown.
    The other date/time places are shown correctly.

    That isn’t happening for me – http://take.ms/roV5e

    Maybe you have Reserved spaced on the datetime from testing tickets?

    2. Date/times in the past are still shown, even if tickets are no longer on sale. (none sold)

    The current code just pulls all the datetimes for an event.

    You could use $datetimes = $event->datetimes_ordered( FALSE, FALSE ); to pull the datetimes in the same order they are within the event editor, the first FALSE tells the function not to include expired datetimes, the second tells the function not to include deleted datetimes.

    3. The sequence of date/times shown doesn’t take year into account; e.g. 17-18 March 2018 is shown before 18-19 March 2017.

    The method used does not do any ordering at all, it just pulls the datetimes from the event.

    The above could also be used to prevent that, I’ve update my gist to include another example which dipslays the same details using the other hook.


    nmaddock

    April 6, 2017 at 3:21 am

    Thanks for that Tony.

    Will re-test as I’m sure that point 1 wasn’t down to any reserved tickets..!

    Viewing 12 reply threads

    The support post ‘Show all events with places remaining’ 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.

    Event Espresso