Skip to content

Instantly share code, notes, and snippets.

@sumnermic
Created June 15, 2020 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sumnermic/e8ced5623097beba5c94db1771897679 to your computer and use it in GitHub Desktop.
Save sumnermic/e8ced5623097beba5c94db1771897679 to your computer and use it in GitHub Desktop.
Get Tribe Event ID from $product object
<?php
// This is useful for when you would like to get the event ID but only have the product object in WooCommerce.
// For example, you would like to get the event ID from an order line item.
$product_id = $product->get_id();
$ticket_meta = get_post_meta( $product_id );
$event_id = absint( $ticket_meta['_tribe_wooticket_for_event'][0] );
@vicsbm
Copy link

vicsbm commented Mar 28, 2023

Thanks for sharing this code.

Can you also give an idea (or the opposite of this code) of how to get the product data associated w/the event ID?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment