Output the original number of tickets in the frontend event list

Home Forums Ticket Products Event Tickets Plus Output the original number of tickets in the frontend event list

  • This topic has 7 replies, 2 voices, and was last updated 6 years ago by salilou.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1498426
    salilou
    Participant

    Hi,
    I use the Ticket Plus plugin and would like to output the original number of tickets in the frontend event list.
    Something like “5 of 10 tickets available”.
    At the moment there is only “5 tickets available”.
    This should of course calculate all ticket types.
    Is that possible by using a hook or filter?
    Thank you!

    #1500702
    Andras
    Keymaster

    Hi Salilou,

    Thanks for reaching out!

    Let me try to help you out with this question. Though we are limited supporting customizations as stated in our support policy, I can try to give you some pointers here.

    For what you want to achieve probably a template override (or more if you want this on several views, like month view and single event view as well) would be best. You can find a guide on template overrides in our Themer’s Guide – https://theeventscalendar.com/knowledgebase/themers-guide/

    And here are three functions from our documentation which will help you show the number of tickets:

    Hope this help you get started. Let me know if you need further guidance.

    Cheers,
    Andras

    #1507712
    salilou
    Participant

    Thank you, Andras!
    But is there a function to get the total amount of tickets?
    I do not mean the still available, but the original total number.
    Greetings,
    Hannes

    #1507938
    Andras
    Keymaster

    Hi Hannes,

    I believe you are looking for this functions then:

    Does this do the trick?

    Andras

    #1508401
    salilou
    Participant

    Thank you Andras, that’s it!
    Now I have to hook in the function tribe_tickets_buy_button in the file
    event-tickets/src/template-tags/tickets.php, line 178
    Do I have to copy the whole file to my child theme (what I would like to avoid)
    or can I use a hook?
    My aim is to change the text before the button from
    “%s tickets left”
    to
    “%s of %s tickets left”
    Thank you!

    #1508887
    Andras
    Keymaster

    You should be able to hook into this filter:

    apply_filters( 'tribe_tickets_buy_button', $html, $parts, $types, $event_id );

    (Line 275 in the same file.)

    It will probably be the ‘$html’ variable that you’ll need to change.

    Does this help?

    Andras

    #1513028
    salilou
    Participant

    Thank you. I have built a code snippet.
    For anyone who also wants to output the total ticket capacity.

    /* add original total ticket capacity */
    add_filter('tribe_tickets_buy_button', 'salilou_tribe_tickets_buy_button');
    function salilou_tribe_tickets_buy_button($html) {
    $my_ticket_capacity = tribe_tickets_get_capacity( $event_id );
    $html['stock'] = str_replace('', ' of ' . $my_ticket_capacity . '', $html['stock']);
    return $html;
    }

    #1513500
    Andras
    Keymaster

    Hi Hannes,

    This is awesome, thanks for sharing that!

    Since this is marked resolved I am going to close this ticket, but if you need anything else related to this topic or another please create a new ticket and we’ll be happy to help.

    Cheers,
    Andras

    PS: We’d be grateful if you would give us feedback on your satisfaction with support. Just click on one of the classy looking emojis below. 🙂 If you can spare a few words, that’s even better. Thanks!

    PS2: If you like our plugins, and you didn’t yet do so 🙂 we would also be happy to receive a review in the wordpress.org repository. Much appreciated!
    https://wordpress.org/support/view/plugin-reviews/the-events-calendar/
    https://wordpress.org/support/view/plugin-reviews/event-tickets/

     

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Output the original number of tickets in the frontend event list’ is closed to new replies.