Getting woocommerce product ID via tribe_get_events

Home Forums Calendar Products Events Calendar PRO Getting woocommerce product ID via tribe_get_events

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1130792
    Web Futago
    Participant

    Hi there… I’m trying to do a loop through all my events in a category, then output the start date along with the Woocommerce product ID for the associated ticket. I’m using Events Calendar Pro with Events Tickets Plus. What I’ve got so far works, but I don’t know how to get the ticket product ID for a given event.

    <?php
                  $events = tribe_get_events(array(
                      'tribe_events_cat' => 'restaurant'
                  ));
                  $start_date = date_format(date_create(get_post_meta($event->ID, '_EventStartDate', true)),"l F j");
                  $product_id = '' //This should be the product ID of the ticket
                  if ( empty( $events ) ) {
                      echo '<option>No events found</option>';
                  }
                  else foreach( $events as $event ) {
                    echo '<option value="'.$product_id.'">'.$start_date.'</option>';
                  }
                ?>

    Hope that makes sense! Let me know if you need more info to help out.

    #1131188
    Josh
    Participant

    Hey Phil,

    Thanks for reaching out to us!

    We don’t appear to have any meta on the event side that stores an array of the tickets (WooCommerce Product Ids) associated with that event. However, for each event, you could do a query on the product post type and get all the product ids with a meta value for the”_tribe_wooticket_for_event” meta key that matches your current event.

    Let me know if this helps.

    Thanks!

    #1137324
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Getting woocommerce product ID via tribe_get_events’ is closed to new replies.