Getting the stock of a specific ticket (id/sku)

Home Forums Ticket Products Event Tickets Plus Getting the stock of a specific ticket (id/sku)

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1257215
    David Hager
    Participant

    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.

    #1257759
    Cliff
    Member

    Hi. 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.

    #1257962
    David Hager
    Participant

    Hi 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!

    #1258445
    Cliff
    Member

    Here 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.

    #1258703
    David Hager
    Participant

    Hi 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;
    }?>
    #1258917
    Cliff
    Member

    Great. Thanks for sharing with others, too!

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Getting the stock of a specific ticket (id/sku)’ is closed to new replies.