Home Forums WoodMart support forum How to show image thumbnail to order detail page

How to show image thumbnail to order detail page

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #148034

    KH
    Participant

    Hello, how can I add product thumbnails in order detail page (my account page > order > view)? Make it looks the same to the cart page. When you add a profuct to a cart, you will see a product thumbnail.

    Attachments:
    You must be logged in to view attached files.
    #148053

    Hello,

    Sorry it is not possible to display the product thumbnail in the view-order page with the theme options.

    It requires customization and this is beyond our limitations and support policy.

    Best Regards.

    #148324

    KH
    Participant

    No problem, this code works just fine.

    
    // Display the product thumbnail in order view pages
    add_filter( 'woocommerce_order_item_name', 'display_product_image_in_order_item', 20, 3 );
    function display_product_image_in_order_item( $item_name, $item, $is_visible ) {
        // Targeting view order pages only
        if( is_wc_endpoint_url( 'view-order' ) ) {
            $product   = $item->get_product(); // Get the WC_Product object (from order item)
            $thumbnail = $product->get_image(array( 150, 150)); // Get the product thumbnail (from product object)
            if( $product->get_image_id() > 0 )
                $item_name = '<div class="item-thumbnail" style="float:left;display:block;width:150px; margin-right:10px;" >' . $thumbnail . '</div>' . $item_name;
        }
        return $item_name;
    }

    Cr: https://stackoverflow.com/questions/50936156/add-the-product-image-to-woocommerce-my-account-order-view

    #148354

    Hello,

    We are glad that you resolve your issue by yourself, You are the best :-),

    And thanks for sharing the solution on Forum, Surely it will help other customers as well.

    If you need any help in future, please feel free to contact us anytime, we are always here to help you. Thanks for contacting us.

    Have a great day :-)

    Topic Closed.
    Best Regards.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘How to show image thumbnail to order detail page’ is closed to new replies.