I am trying to determine if any items in a Woocommerce shopping cart are events or not. The tribe_is_event()
function doesn't seem to be working as expected, as it always returns false. I'm thinking I'm misunderstanding it's usage.
In the following, I'm looping over all cart items and simply echoing out whether or not it's an event. It always returns "This is normal product", regardless of the type of product it is.
add_action('woocommerce_before_checkout_form', function ($checkout) {
$items = WC()->cart->get_cart();
foreach ($items as $item => $values) {
$post_id = $values['data']->get_id();
// Why does this not work?
if(tribe_is_event($post_id)){
echo 'This is an event!';
}else{
echo 'This is normal product';
}
}
});
I have logged the $post_id
to ensure it's actually the product id I think it is. I've read what I could find online about the function. I feel like it should work in telling me if the product is an event.
Any help would be great :)