Tuesday, July 17, 2018

how to show product image on check out page woocommerce

WooComerce is a great plugin to add awesome eCommerce functionality in a WordPress website, but we missed many core features like how do we show product image beside product title on check out page.

I brought to you this solution, I am sure it will help you. cheers.
I have setup an instance on local PC with storefront theme. so , I have created a new file named yourcustomfunctions.php and put this file into inc folder in theme root folder and include this file into main functions.php file to make my work separate.
Step by step solution is here:

Step 1. Create a new .php file into inc folder on your theme 's root.









Step 2. Place this function into it.
  function displays_cart_products_feature_image() {
              foreach ( WC()->cart->get_cart() as $cart_item ) {
                  $item = $cart_item['data']; $productid = $item->id;
                 // product id
                 $image = wp_get_attachment_image_src( get_post_thumbnail_id( $productid ), 'single-post-thumbnail' );
                 $productimgURL = $image[0]; return $productimgURL;
                 // Return product image 's url
        }






 Step3. Place your function on review-order.php file to see the result as It can be seen on screenshot below.
The place on file where you want to place the code:






See the result on website:














Enjoy the solution. If you need any help on this please write me back in comments.



Cheers














No comments:

Post a Comment