Get Event ID from Ticket ID

Home Forums Ticket Products Event Tickets Plus Get Event ID from Ticket ID

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1088196
    Dan Feeley
    Participant

    What’s the current method for retrieving the Event ID from the Ticket ID?

    I ran across this one in another post but I guess it no longer works:

    $tribe_woo = Tribe__Events__Tickets__Woo__Main::get_instance();
    $ticket_product = class_exists( 'WC_Product_Simple' ) ? new WC_Product_Simple( $ticket_id ) : new WC_Product( $ticket_id );

    $event = $tribe_woo->get_event_for_ticket( $ticket_product );

    #1088321
    George
    Participant

    Hey @danfeeley,

    If you have that $ticket_id variable, you should be able to get the Event ID for the event with which it’s associated by using code like the following:

    $event_id = get_post_meta( $ticket_id, '_tribe_wooticket_for_event', true );

    $event_id will now be the Event ID.

    I hope this helps!

    — George

    #1088368
    Dan Feeley
    Participant

    That worked great, thank you.

    #1088639
    George
    Participant

    Nice! Cheers. 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Get Event ID from Ticket ID’ is closed to new replies.