将产品缩略图添加到我的帐户-最近的订单-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();
}
?>

Leave a Reply

Your email address will not be published. Required fields are marked *