L
L
leoelena2019-05-28 17:21:19
WooCommerce
leoelena, 2019-05-28 17:21:19

How to add product image and short description to Woocommerce emails?

Such code is written in functions.php, but the picture does not appear, only an empty space, and its size is 32x32.

function sww_add_images_woocommerce_emails( $output, $order ) {

    // set a flag so we don't recursively call this filter
    static $run = 0;

    // if we've already run this filter, bail out
    if ( $run ) {
        return $output;
    }

    $args = array(
        'show_sku'      => false,
        'show_image'    => true,
        'image_size'    => array( 500, 500 ),
    );

    // increment our flag so we don't run again
    $run++;

    // if first run, give WooComm our updated table
    return $order->email_order_items_table( $args );
}
add_filter( 'woocommerce_email_order_items_table', 'sww_add_images_woocommerce_emails', 10, 2 );

And a short description of the product must be added to the letter to the client with the order.
Thank you for your help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
leoelena, 2019-06-05
@leoelena

Unfortunately, you won’t get support and answers on our forums)
I didn’t understand how I got pictures in letters, but I added a brief description like this.
In functions.php

add_action( 'woocommerce_order_item_meta_start', 'dw_order_item_meta_start', 10, 4 );
function dw_order_item_meta_start( $item_id, $item, $order, $plain_text ){
    $description = $item->get_product()->get_short_description();
    if(!empty($description)) {
        echo " ({$description})";       
    }
}

In the email-order-items.php in the child theme, this is:
Hope it helps someone.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question