Title: variation image
Last modified: July 1, 2018

---

# variation image

 *  [yatgirl](https://wordpress.org/support/users/yatgirl/)
 * (@yatgirl)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/variation-image/)
 * Hi
    I have the following code which works to add the product image to the invoice,
   but in the case of variations (grey shirt(main product image) vs red shirt (variation
   image), it doesnt add the variation image to the invoice, just the main product
   image.
 *     ```
       // Add Image To Order
       function example_product_image( $product ) {    
           if( isset( $product->id ) && has_post_thumbnail( $product->id ) ) {
               echo get_the_post_thumbnail( $product->id, array( 80, 80 ) );
           }
       }
       ```
   
 * How do I add the actual variation image, as it shows on the order screen, instead
   of the main product image ?

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Thread Starter [yatgirl](https://wordpress.org/support/users/yatgirl/)
 * (@yatgirl)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/variation-image/#post-10515966)
 * Is there any answer for this ?
 *  Plugin Author [priyankajagtap](https://wordpress.org/support/users/priyankajagtap/)
 * (@priyankajagtap)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/variation-image/#post-10518152)
 * Hi [@yatgirl](https://wordpress.org/support/users/yatgirl/),
 * I apologize for the delay in response.
 * Thank you for sharing the code snippet. To display the variation images in the
   invoice and delivery note, we will need to check on how we can modify the code
   for the variable products. I will discuss this with my development team and soon
   I will get back to you with an update on the same. I hope that is fine.
 * Please let me know if you have any questions.
 * Regards,
    Priyanka Jagtap
 *  Thread Starter [yatgirl](https://wordpress.org/support/users/yatgirl/)
 * (@yatgirl)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/variation-image/#post-10714665)
 * Hi
    I was just wondering if there might be any update or solution?
 *  Plugin Author [priyankajagtap](https://wordpress.org/support/users/priyankajagtap/)
 * (@priyankajagtap)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/variation-image/#post-10717518)
 * Hi [@yatgirl](https://wordpress.org/support/users/yatgirl/),
 * I apologize for not getting back to you on this.
 * Kindly replace the below-provided code with your existing code in your active
   theme’s functions.php file and check whether the variation images are displaying
   in the invoice or not.
 * Code:
    `function example_product_image( $product, $order ) { if( has_post_thumbnail(
   $product->get_id() ) ) { echo get_the_post_thumbnail( $product->get_id(), array(
   250 , 250 ) ); } } add_action( ‘wcdn_order_item_before’, ‘example_product_image’,
   10, 2 );
 * Please do the same and let me know the result.
 * Regards,
    Priyanka Jagtap
 *  Thread Starter [yatgirl](https://wordpress.org/support/users/yatgirl/)
 * (@yatgirl)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/variation-image/#post-10718776)
 * Thanks ! – Yes that works well.
 * The only thing to note for anyone else needing this code is that a variation 
   image needs to be set for each variation or the invoice will not bring back any
   image at all. So say if you have a Tshirt in only one color, but variable sizes–
   an image needs to be set for each size variation on the product entry page, even
   tho the pic for all sizes is the same. ( I hadnt done this before, but I will
   now)
 * Thanks again !
 *  Plugin Author [priyankajagtap](https://wordpress.org/support/users/priyankajagtap/)
 * (@priyankajagtap)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/variation-image/#post-10721427)
 * Hi [@yatgirl](https://wordpress.org/support/users/yatgirl/),
 * Thank you for sharing the information. I am sure this will help other customers.
   Also, I am glad to know that the provided code is helpful for you to achieve 
   your requirement. 🙂
 * Let us know if you have any questions.
 * Regards,
    Priyanka Jagtap

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘variation image’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-delivery-notes/assets/icon-256x256.jpg?rev=2829362)
 * [Print Invoice & Delivery Notes for WooCommerce](https://wordpress.org/plugins/woocommerce-delivery-notes/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-delivery-notes/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-delivery-notes/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-delivery-notes/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-delivery-notes/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-delivery-notes/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [priyankajagtap](https://wordpress.org/support/users/priyankajagtap/)
 * Last activity: [7 years, 8 months ago](https://wordpress.org/support/topic/variation-image/#post-10721427)
 * Status: not resolved