I wanted to be able to show the event image in the shopping cart nstead of the placeholder image (if there isnt already a product image). So i wrote a short function that I’d like to share here.
I hope this is the appropriate place for sharing this snippet.
/* use event image, if there isnt a product image */
add_filter( 'woocommerce_cart_item_thumbnail', 'reach_cart_image_event', 10, 3);
function reach_cart_image_event($product_image, $cart_item, $cart_itemkey) {
if (strpos($product_image, "placeholder")) {
$ticket_meta = get_post_meta( $cart_item['product_id'] );
$event_id = absint( $ticket_meta['_tribe_wooticket_for_event'][0] );
if ($event_id) {
$event_image = get_the_post_thumbnail($event_id, "shop_thumbnail");
if ($event_image) {
$product_image = $event_image;
}
}
}
return $product_image;
}