在自定义管理员订单电子邮件中显示Woocommerce产品图片

时间:2020-10-28 08:46:50

标签: php html woocommerce

因此,我为在线商店制作了一个自定义管理员订单模板(重新样式和重新安排了很多)。我已经知道“显示图像=>假/真” ,这不是我想要的答案,因为我完全更改了电子邮件模板中的所有内容。现在我的问题是我不知道如何显示产品图片。

欢迎任何帮助,因为我是编码新手。

编辑: 这是我现在遇到的错误: src =“ 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:无;显示:行内块;字体-大小:14像素;字体粗细:粗体;高度:自动;轮廓:无;文本修饰:无;文本转换:大写;垂直对齐:中间;右边距:10像素;最大宽度:100%;” >

这是我的代码:

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

1 个答案:

答案 0 :(得分:0)

这对我的问题有所帮助,希望其他人也可以使用它。这将获取产品图片的网址。 <?php printf( esc_html__(get_the_post_thumbnail_url($product->get_id())));?>