我想知道是否有一种方法可以在Woocommerce前端的"我的帐户"中将产品缩略图添加到买方的"最近订单"页面中。
我一直在试图找到某种解决办法,但从来没有运气。
我没有尝试过给你一个代码,只是因为我不知道如何
有人能给我指个正确的方向吗?您需要编辑templates/myaccount/my-orders.php
。将以下代码添加到您希望显示缩略图的位置。
<?php
// Get a list of all items that belong to the order
$products = $order->get_items();
// Loop through the items and get the product image
foreach( $products as $product ) {
$product_obj = new WC_Product( $product["product_id"] );
echo $product_obj->get_image();
}
?>