Jan*_*res 0 php wordpress image orders woocommerce
在woocommerce中,在“收到订单”页面(“谢谢”页面)上,产品图像未显示在订单项中。
如何在“已收到订单”页面上的订单项中显示产品图片?
是否有可用的挂钩?
还是我必须覆盖模板order/order-details-item.php文件?
任何帮助表示赞赏。
要在“已收到订单”页面上的订单项中显示缩略图,(谢谢),您将使用:
// Display the product thumbnail in order received page
add_filter( 'woocommerce_order_item_name', 'order_received_item_thumbnail_image', 10, 3 );
function order_received_item_thumbnail_image( $item_name, $item, $is_visible ) {
// Targeting order received page only
if( ! is_wc_endpoint_url('order-received') ) return $item_name;
// Get the WC_Product object (from order item)
$product = $item->get_product();
if( $product->get_image_id() > 0 ){
$product_image = '<span style="float:left;display:block;width:56px;">' . $product->get_image(array(48, 48)) . '</span>';
$item_name = $product_image . $item_name;
}
return $item_name;
}
Run Code Online (Sandbox Code Playgroud)
代码进入您的活动子主题(或活动主题)的function.php文件中。经过测试和工作。
| 归档时间: |
|
| 查看次数: |
542 次 |
| 最近记录: |