Support

Home Forums Event Espresso Premium Tickets remaining

Tickets remaining

Posted: June 20, 2017 at 11:09 am


lupineart

June 20, 2017 at 11:09 am

Hi guys,

Just getting around to finishing this up: https://eventespresso.com/topic/tickets-soldremaining/#post-238882

I added the following to customization plugin:

function my_print_tickets_left_after_selector($atts) {
    global $wpdb;

    $EVT_ID = get_the_ID();

    	$x = 'Remaining Spaces for this Camp: ';

        $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 ));
        
        $remaintotal = 0;

        foreach($datetimes as $datetime){
            $limit = $datetime->DTT_reg_limit;
            $sold = $datetime->DTT_sold;
            $remaintotal += $limit - $sold;
            $remain = $limit == -1 ? '' : $remaintotal;
        }

        $x .= $remain;
 
    return $x;
 
}
add_shortcode('show_capacity','my_print_tickets_left_after_selector');

Event link – https://lupineart.com/events/painting-with-jennifer-mcintyre/

But, it doesn’t appear to have changed anything on the front end. I suspect it may be blocked by css or another setting somewhere?

Please advise, thanks.


Josh

  • Support Staff

June 20, 2017 at 11:29 am

Hi there,

That particular snippet actually adds support for a new shortcode for you to use. So within the event’s description, where you want that tickets remaining message displayed, you place [show_capacity], then you update the event.


lupineart

June 20, 2017 at 11:42 am

Thanks Josh, that’s really useful for me to use in the excerpts on my class listings pages. But, is there a way to get this into the ticket selector somewhere? Ideally, I would like something like this:

https://www.dropbox.com/s/g4p86dmhqxkcmwq/Screenshot%202017-06-20%2010.40.54.png?dl=0

Thanks, Derek


lupineart

June 20, 2017 at 1:24 pm

Further to this, I put it into an event that has multiple datetimes and tickets – https://lupineart.com/events/mixed-media/

It says that there are 45 seats remaining, when there should only be 15. There are tickets each with a limit of 15 and 3 datetimes each with a limit of 15. I realize that it’s just adding up all of the datetimes.

How do we work around displaying only how many seats are left (i.e. the max # of registrations for the event before it sells out)?

I put in 2 snippets, the one that creates the shortcode and the one that displays spaces after the ticket selector (just to test it out).

If I can’t get the spaces available in the ticket selector per my previous message, I will do one of the 2 options currently in place. However, I would like them to read 15 spaces available, not 45, in this example.

Thanks


Josh

  • Support Staff

June 21, 2017 at 6:39 pm

Hi Derek,

The code from that other forum topic isn’t well suited for what you’re trying to accomplish. You’re actually trying to print something like this right?

But would like to show TICKETS SOLD in place of the ‘REMAINING TICKETS’ and show XX / XX (sold / total available) in place of XX (remaining tickets).


Josh

  • Support Staff

June 21, 2017 at 7:04 pm

This snippet might be more what you’re looking for:

https://gist.github.com/joshfeck/777cc126964a25c15962f2c14aa3eb82


lupineart

June 21, 2017 at 7:29 pm

Hi Josh,

Thanks for all of this help, but it’s just not quite what I’m looking for, mainly due to the multiple datetimes and various ticket types (some offer multiple datetimes, some are single). i.e. 45 seats left is mislead when the tickets have 3 datetimes for each (there’s really only 15 seats left).

Is there a way to show how many tickets remain inside the ticket selector, like in this screen shot? https://www.dropbox.com/s/g4p86dmhqxkcmwq/Screenshot%202017-06-20%2010.40.54.png?dl=0

I think there is ‘tickets remaining’ in the default details setup within the ticket selector, but I don’t like that area as I find it cluttered and confusing to a buyer (too much info and they have to expand it).

Thanks again, really appreciate it…


lupineart

June 21, 2017 at 7:52 pm

Hi Josh – I think found what I’m looking for, here: https://gist.github.com/lorenzocaum/a6610712a59cf29cca58

And that does exactly what I want. I thought I tried it awhile ago and got some error.

Only thing, I’d like to:
– Not show the +Details and the /Ticket
– Show the * to be beside the price to denote Tax extra
– Show ‘price does not include taxes’ below

Does the template override these settings that were in place before?

Thanks Josh…


Josh

  • Support Staff

June 22, 2017 at 10:30 am

Hi Derek,

The tutorial you linked to has some very out of date code. The thing about the ticket selector there’s iteration involved where new features get added, and the tutorial you linked to is giving instructions on replacing the entire ticket selector template. I do not recommend replacing the entire ticket selector template just to make a few edits, you’ll end up having to maintain a significant amount of code to keep things working.

With regards to the last gist I linked to, I put that code together with the goal to avoid any potential issues with multiple datetimes and various ticket types. This is because the code doesn’t count multiple datetimes, it only counts approved registrations for that event. So please give that code a try before concluding that it’s not going to work for you.


lupineart

June 22, 2017 at 11:45 am

Hi Josh,

Ok, I appreciate that, thanks.

I did try that code… My issue is that I think it’s a misleading number for prospective buyers. What I really want is to show how many tickets are left in the ticket selector like my earlier screenshot. The code you provided seems to add it all up. For example, this page: https://lupineart.com/events/family-clay-camp/

Shows there are 60 total seats available to sell (which technically is true), but that’s not what I want to show buyers.

What I really want it to show is how many seats left for each ticket. I think it’s a different perception from a buyer. It shows which days (tickets) have more room than others, rather than a large number (60) at the bottom.

So what you are saying is that it’s not recommended to work within the ticket selector?

Thanks, Derek


Josh

  • Support Staff

June 22, 2017 at 12:23 pm

So what you are saying is that it’s not recommended to work within the ticket selector?

No I’m not saying that. The ticket selector can be worked with, but any changes should be made via filter hooks instead of completely overriding the template. When you completely override the template you’ll need to continually monitor Event Espresso core’s changes to that template and maintain your customizations.


lupineart

June 22, 2017 at 12:39 pm

Ok, got it. Thanks, Josh.

Would you have the code required to achieve what I want (or close)? Or go to a developer for that?

Thanks


Josh

  • Support Staff

June 27, 2017 at 8:07 am

Hi Derek,

The ticket selector does not have the hooks that would allow for making that type of customization. There’s the potential for adding more hooks which would allow filtering the contents of the columns and rows within the ticket selector table. This would require a developer to put together and even do a pull request on the project hosted on Github.

The support post ‘Tickets 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