LK-dev
LK-dev

Reputation: 1

Display Woocommerce Product Image in custom admin order email

So I have made a custom admin order template ( restyling and re-arranging a lot ) for a online store. I already know about the "show image => false/true" that is not the answer I'm looking for, because I completely changed everything in my email template. Now my problem is that I don't know how to display the product image.

Any help is welcome because I'm new to coding.

Edit: This Is the bug i have right now: <img class="thumb" src="<img" width="1080" height="1080" alt="Weer Thuis Boeket" loading="lazy" srcset="https://acanthusbloememotie.nl/staging/wp-content/uploads/2020/07/14.png 300w, https://acanthusbloememotie.nl/staging/wp-content/uploads/2020/07/14.png 1024w, https://acanthusbloememotie.nl/staging/wp-content/uploads/2020/07/14.png 150w, https://acanthusbloememotie.nl/staging/wp-style="border: none; display: inline-block; font-size: 14px; font-weight: bold; height: auto; outline: none; text-decoration: none; text-transform: capitalize; vertical-align: middle; margin-right: 10px; max-width: 100%;">

Here is my code:

<figure>
    <?php
    foreach ($order->get_items() as $key => $lineItem) {

        //uncomment the following to see the full data
        // echo '<pre>';
        // print_r($lineItem);
        // echo '</pre>';
        $product_id = $lineItem['product_id'];
        $product = wc_get_product( $product_id );
        printf( '<img class="thumb" src=' . $product->get_image('full')  . ' ');
    }
    ?>
</figure>

Upvotes: 0

Views: 582

Answers (1)

LK-dev
LK-dev

Reputation: 1

This has helped me with my problem, hopefully others can use it too. this gets the URL of the product image. <?php printf( esc_html__(get_the_post_thumbnail_url($product->get_id())));?>

Upvotes: 0

Related Questions