Home Forums Plugins WooCommerce Email Template Customizer Duplicate product image on email

Duplicate product image on email

  • Author
    Posts
  • #132177

    Toni
    Participant

    Hi!

    Im having trouble with the email customizer. It picks second product image from thank you page to all emails that have product image. I don’t understand how it adds it to the emails.

    Im using this snippet to add image to thank you page.

    /**
    * @snippet WooCommerce Show Product Image @ Thankyou Page
    * @author Sandesh Jangam
    * @donate $9 https://www.paypal.me/SandeshJangam/9
    */

    add_filter( ‘woocommerce_order_item_name’, ‘ts_product_image_on_thankyou’, 10, 3 );

    function ts_product_image_on_thankyou( $name, $item, $visible ) {

    /* Return if not thankyou/order-received page */
    if ( ! is_order_received_page() ) {
    return $name;
    }

    /* Get product id */
    $product_id = $item->get_product_id();

    /* Get product object */
    $_product = wc_get_product( $product_id );

    /* Get product thumbnail */
    $thumbnail = $_product->get_image();

    /* Add wrapper to image and add some css */
    $image = ‘<div class=”ts-product-image” style=”width: 52px; height: 52px; display: inline-block; padding-right: 7px; vertical-align: middle;”>’
    . $thumbnail .
    ‘</div>’;

    /* Prepend image to name and return it */
    return $image . $name;
    }

    Attachments:
    You must be logged in to view attached files.

You must be logged in to see replies to this topic. Click here to login or register