[英]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.