Created
June 15, 2020 13:52
-
-
Save sumnermic/e8ced5623097beba5c94db1771897679 to your computer and use it in GitHub Desktop.
Get Tribe Event ID from $product object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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] ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?