• Resolved haris6007

    (@haris6007)


    Hi,

    I read the FAQ in which you explain how to add image in the invoice.

    I tried to run the suggested code by placing it in functions.php file in my standard storefront woocommerce theme – BUT NOTHING HAPPENS..

    I need help please. I simply want to display image thumbnail in invoice

    –haris

    function example_product_image( $product ) {
    if( isset( $product->id ) && has_post_thumbnail( $product->id ) ) {
    echo get_the_post_thumbnail( $product->id, array( 40, 40 ) );
    }
    }
    add_action( ‘wcdn_order_item_before’, ‘example_product_image’ );

    • This topic was modified 8 years, 6 months ago by haris6007.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hey Haris6007,
    I was just passing by, Your code looks correct and is the same as what I am using, but I have mine within my Child – storefront Functions file. If you are using a Child theme, you need to put it within that I think.
    Perhaps the Moderator can provide some insight.

    Plugin Author Vishal Kothari

    (@ashokrane)

    Hi @haris6007,

    The code is right, but you have placed it at the wrong place.

    I put your code within the main class file along with the callback function & that’s when it worked. It didn’t work when I put the code outside of the class file.

    add_action( ‘wcdn_order_item_before’, array( $this, ‘example_product_image’ ) );

    Here is how my main file: woocommerce-delivery-notes.php looks like: https://screencast.com/t/m85LBUiY

    Alternatively, as @mowlman mentioned, you can also add this piece of code which you gave in your child theme’s functions.php file. Even that worked fine for me.

    Here is how my invoice looked: https://screencast.com/t/KRrXEmJZmX

    I hope this helps.

    :Vishal

    Alright, I just installed this plugin, and this reference was the only thing I found when I went looking to add images to my invoice. I’ve used the code as referenced here, and added it to my woocommerce-delivery-notes.php file, but am not getting the thumbnails on my invoice. Is there something else that I need to do that I totally missed?

    Thanks!

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

The topic ‘add image to invoice’ is closed to new replies.