• 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

    (@yatgirl)

    Is there any answer for this ?

    Plugin Author priyankajagtap

    (@priyankajagtap)

    Hi @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

    (@yatgirl)

    Hi
    I was just wondering if there might be any update or solution?

    Plugin Author priyankajagtap

    (@priyankajagtap)

    Hi @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

    (@yatgirl)

    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

    (@priyankajagtap)

    Hi @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.