mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-05-01 11:52:25 +08:00
https://stackoverflow.com/questions/66151448/display-product-thumbnails-on-woocommerce-my-account-orders-list/66152103
13 lines
690 B
Text
13 lines
690 B
Text
add_action( 'woocommerce_my_account_my_orders_column_order-number', 'my_account_orders_product_thumbnails', 20, 1 );
|
|
function my_account_orders_product_thumbnails( $order ) {
|
|
echo '<a href="'. wc_get_endpoint_url('view-order') . $order->get_id() . '/' . '">' . '#' . $order->get_order_number() . '</a>';
|
|
|
|
// Loop through order items
|
|
foreach( $order->get_items() as $item ) {
|
|
$product = $item->get_product(); // Get the WC_Product object (from order item)
|
|
$thumbnail = $product->get_image(array( 36, 36)); // Get the product thumbnail (from product object)
|
|
if( $product->get_image_id() > 0 ) {
|
|
echo ' ' . $thumbnail;
|
|
}
|
|
}
|
|
}
|