Event Thumbnail in woocommerce cart

Home Forums Ticket Products Event Tickets Plus Event Thumbnail in woocommerce cart

  • This topic has 1 reply, 2 voices, and was last updated 8 years ago by Nico.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1110662
    ellsworthamerican
    Participant

    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;
    }

    #1110932
    Nico
    Member

    Hey @ellsworthamerican,

    Thanks for sharing your code 🙂 It will surely be useful for other folks! Also the forums is a good place as many users search before posting.

    The code looks great, I just wrapped it around code tags so the tabs get displayed as well.

    Thanks once again,
    Best,
    Nico

Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘Event Thumbnail in woocommerce cart’ is closed to new replies.