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



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

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

编辑:这是我现在遇到的错误:<img class="拇指src="<img">width=";1080〃;高度=";1080〃;alt=";Weer Thuis Boeket";负载=";懒惰;srcset=";https://acanthusbloememotie.nl/staging/wp-content/uploads/2020/07/14.png300w,https://acanthusbloememotie.nl/staging/wp-content/uploads/2020/07/14.png1024w,https://acanthusbloememotie.nl/staging/wp-content/uploads/2020/07/14.png150w,https://acanthusbloememotie.nl/staging/wp-style="边界:无;显示:内联块;字体大小:14px;font weight:bold;高度:自动;大纲:无;文字装饰:无;文本转换:大写;垂直对齐:居中;右侧边距:10px;最大宽度:100%"gt;

这是我的代码:

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

这帮助我解决了问题,希望其他人也能使用它。这将获得产品图像的URL。<?php printf( esc_html__(get_the_post_thumbnail_url($product->get_id())));?>

最新更新