0
votes

I made a copy of the file "email-order-details.php" to my child theme. Now I can modify the html, but would like to add an extra column to my table for the product image. With this code I am able to display the image and sku, but it's in the same column with product name, sku, product description.

        <?php
        echo wc_get_email_order_items( $order, array( // WPCS: XSS ok.
            'show_sku'      => $true,
            'show_image'    => false,
            'image_size'    => array( 32, 32 ),
            'plain_text'    => $plain_text,
            'sent_to_admin' => $sent_to_admin,
        ) );
        ?>

I also want to display the sku without the () and I want to place it on top of the column. I think there must be an array or variables or something like this to get the dates.

This line, for example displays the Price, can anybody tell me how to display sku and product image in the same way?

<th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Price', 'woocommerce' ); ?></th>

Thank you in advance

1
The product image and sku are already included in the template emails/email-order-items.php that is called on most of email-notifications…LoicTheAztec
That's it. Thank you very very much LoicTheAztecmaariaa

1 Answers

0
votes

try this snippet code, I use this in functions.php in child theme:

function sww_add_wc_order_email_images( $table, $order ) {

ob_start();

$template = $plain_text ? 'emails/plain/email-order-items.php' : 'emails/email-order-items.php';
wc_get_template( $template, array(
    'order'                 => $order,
    'items'                 => $order->get_items(),
    'show_download_links'   => $show_download_links,
    'show_sku'              => $show_sku,
    'show_purchase_note'    => true,
    'show_image'            => true,
    'image_size'        => array( 200, 200 )
) );

return ob_get_clean();
}
add_filter( 'woocommerce_email_order_items_table', 'sww_add_wc_order_email_images', 10, 2 );