Home › Forums › Ticket Products › Event Tickets Plus › Getting the stock of a specific ticket (id/sku)
- This topic has 6 replies, 3 voices, and was last updated 7 years, 1 month ago by Cliff.
-
AuthorPosts
-
March 21, 2017 at 6:12 am #1257215David HagerParticipant
Hi there,
I’m building a website where customers can buy tickets for attendees as well as tickets for accompanying staff. For these events, a limited number of attendees can apply, but there is enough space for many more of the staff.
I’d like to sell tickets for both the attendees and the staff via Tribe Tickets Plus. In the overview of events I need to show the remaining spots for attendees and make the event say full when there are no more attendee spots left. Afterwards, staff should still be able to order tickets.
I can’t seem to find how to do this. The overview shows all available tickets left, and I want to ignore specific tickets.
A solution could be to show the stock of a specific ticket ID/SKU in the overview. But I can’t find the function for this.
Any help would be great! Thanks.
March 21, 2017 at 8:23 pm #1257759CliffMemberHi. Thanks for your detailed question.
You might be interested in utilizing the Global Stock feature. It’s designed for situations where a venue has a maximum overall capacity but there are different types of tickets being sold that, if all sold out, would be over the venue’s maximum.
This doesn’t sound exactly like what you’re asking for, but it might still help.
As far as the functions to get an event’s stock, please look in this file: /wp-content/plugins/event-tickets/src/template-tags/tickets.php
Please let me know if you have any follow-up questions on this topic.
March 22, 2017 at 6:24 am #1257962David HagerParticipantHi Cliff,
Thanks. At first I tried doing a workaround with the global availability function indeed. (this saved me another time)
In the file you mentioned I find this function, which might do the trick:
tribe_events_partially_soldout();When I would change the output of this function to show a ‘event full’ message when 1 of the tickets would be sold out, it would do the trick. Although I’m not totally sure how to call this function in my loop. (calling a plugin function from a theme file is something new to me…)
Could you give me pointers? Thanks!
March 22, 2017 at 10:29 pm #1258445CliffMemberHere are some snippets that utilize a different function from within that file: https://gist.github.com/search?utf8=%E2%9C%93&q=tribe_events_has_soldout
You could reference those for your own use.
Please let me know how this goes for you.
March 23, 2017 at 9:11 am #1258703David HagerParticipantHi Cliff,
Thanks for your help. I rewrote a function from the
/wp-content/plugins/event-tickets/src/template-tags/tickets.php
file. This returned a 1 when a single ticket was sold-out, which I used to fix the problem. Thanks again!<?php function tribe_events_single_ticket_soldout( $event = null ) { if ( null === ( $event = tribe_tickets_parent_post( $event ) ) ) { return false; } $some_have_soldout = false; foreach ( Tribe__Tickets__Tickets::get_all_event_tickets( $event->ID ) as $ticket ) { if ( ! $some_have_soldout && 0 == $ticket->stock() ) { $some_have_soldout = true; } } return $some_have_soldout; }?>
March 23, 2017 at 11:01 am #1258917CliffMemberGreat. Thanks for sharing with others, too!
-
AuthorPosts
- The topic ‘Getting the stock of a specific ticket (id/sku)’ is closed to new replies.