简体   繁体   English

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

[英]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.我已经知道“show image => false/true”这不是我正在寻找的答案,因为我完全更改了电子邮件模板中的所有内容。 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;编辑:这是我现在的错误:<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;字体大小:14px; font-weight: bold;字体粗细:粗体; height: auto;高度:自动; outline: none;大纲:无; text-decoration: none;文字装饰:无; text-transform: capitalize;文本转换:大写; vertical-align: middle;垂直对齐:中间; margin-right: 10px;右边距:10px; max-width: 100%;">最大宽度: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>

This has helped me with my problem, hopefully others can use it too.这对我的问题有所帮助,希望其他人也可以使用它。 this gets the URL of the product image.这将获取产品图片的 URL。 <?php printf( esc_html__(get_the_post_thumbnail_url($product->get_id())));?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 WooCommerce email 通知上显示自定义产品图像 - Display custom product image on WooCommerce email notifications 在Woocommerce管理员电子邮件通知中显示产品自定义字段值 - Display a product custom field value in Woocommerce admin email notifications 在 WooCommerce 订单管理页面 (ACF) 显示产品自定义字段 - Display product custom field in WooCommerce Order admin Page (ACF) 在 WooCommerce 管理订单页面中保留并显示产品自定义字段值 - Keep and display product custom field value in WooCommerce Admin Order pages 在 WooCommerce 电子邮件订单项目中显示可变产品的产品自定义字段 - Display a product custom field for variable products in WooCommerce email order items 在 WooCommerce 管理订单页面上将产品自定义字段显示为订单项元数据 - Display product custom field as order item meta on WooCommerce admin order pages 在 WooCommerce email 通知中显示产品自定义字段 - Display product custom fields in WooCommerce email notifications 在 WooCommerce email 通知中为管理员显示自定义字段 - Display a custom field in WooCommerce email notifications for admin 在Woocommerce 3中将产品自定义字段显示为订单商品 - Display product custom fields as order items in Woocommerce 3 在 WooCommerce 管理员订单项目上显示产品自定义字段也适用于可变产品 - Display product custom fields on WooCommerce Admin Order Items also for variable products
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM