php - Show product's image in “Orders” page - Woocommerce -


i working wc first time , chasing tail one.

in "orders" page customer's can see purchases they've made array shows basic info order. need show image of product customer bought.

orders seems custom posts, how image product?

i realize question vague. pointers big great help.

orders custom post types of shop_order type. orders not have thumbnails themselves, orders have list of products purchased , each product has possibility of thumbnail.

you can see in order-details.php template how items/products associated order object... $order->get_items()

this returns array of data stored in separate database tables. $item variable can original product , can see in linked template $product variable being sent order-details-item.php defined order->get_product_from_item( $item ).

anyway, once have $product object can use $product->get_image() retrieve product's image.

as simplified example, show thumbnails products purchased in order 999.

$order_id = 999; $order = wc_get_order( $order_id ); foreach( $order->get_items() $item_id => $item ) {         $product = apply_filters( 'woocommerce_order_item_product', $order->get_product_from_item( $item ), $item );         echo $product->get_image(); } 

nesting inside of loop:

foreach ( $customer_orders $customer_order ) {     $order = wc_get_order();     $order->populate( $customer_order );     foreach( $order->get_items() $item_id => $item ) {             $product' = apply_filters( 'woocommerce_order_item_product', $order->get_product_from_item( $item ), $item );             echo $product->get_image();     } } 

though normally, order-details.php template should have links overview of each individual order.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -