wordpress - Show product thumbnail on woocommerce New Order email -


i have wordpress/woocommerce site running , i'd edit email admins receive when new order received show thumbnail of product. copied template theme directory (/themes/mytheme/woocommerce/emails/admin-new-order.php)

    <?php echo $order->email_order_items_table( true, false, true, true, array( 150, 150 )     ); ?> 

and code woocommerce/classes/class-wc-order.php

    /**  * output items display in html emails.  *  * @access public  * @param bool $show_download_links (default: false)  * @param bool $show_sku (default: false)  * @param bool $show_purchase_note (default: false)  * @param bool $show_image (default: false)  * @param array $image_size (default: array( 32, 32 )  * @param bool plain text  * @return string  */ public function email_order_items_table( $show_download_links = false, $show_sku = false, $show_purchase_note = false, $show_image = false, $image_size = array( 32, 32), $plain_text = false ) {      ob_start();      $template = $plain_text ? 'emails/plain/email-order-items.php' : 'emails/email-order-items.php';      woocommerce_get_template( $template, array(         'order'                 => $this,         'items'                 => $this->get_items(),         'show_download_links'   => $show_download_links,         'show_sku'              => $show_sku,         'show_purchase_note'    => $show_purchase_note,         'show_image'            => $show_image,         'image_size'            => $image_size     ) );      $return = apply_filters( 'woocommerce_email_order_items_table', ob_get_clean() );      return $return; } 

this code /plugins/woocommerce/templates/emails

<?php  /**   * email order items   *   * @author         woothemes   * @package    woocommerce/templates/emails   * @version     2.0.3   */        if ( ! defined( 'abspath' ) ) exit; // exit if accessed directly        global $woocommerce;        foreach ($items $item) :  // get/prep product data $_product = $order->get_product_from_item( $item ); $item_meta = new wc_order_item_meta( $item['item_meta'] ); $image = ($show_image) ? '<img src="/wp/'. current(wp_get_attachment_image_src( get_post_thumbnail_id( $_product->id ), 'thumbnail')) .'" alt="img" height="'.$image_size[1].'" width="'.$image_size[0].'" style="vertical-align:middle; margin-right: 10px;" />' : '';  ?> <tr>     <td style="text-align:left; vertical-align:middle; border: 1px solid #eee; word-wrap:break-word;"><?php          // show title/image etc         echo    apply_filters( 'woocommerce_order_product_image', $image, $_product, $show_image);          // product name         echo    apply_filters( 'woocommerce_order_product_title', $item['name'], $_product );          // sku         echo    ($show_sku && $_product->get_sku()) ? ' (#' . $_product->get_sku() . ')' : '';          // file urls         if ( $show_download_links && $_product->exists() && $_product->is_downloadable() ) {              $download_file_urls = $order->get_downloadable_file_urls( $item['product_id'], $item['variation_id'], $item );              $i = 0;              foreach ( $download_file_urls $file_url => $download_file_url ) {                 echo '<br/><small>';                  $filename = woocommerce_get_filename_from_url( $file_url );                  if ( count( $download_file_urls ) > 1 ) {                     echo sprintf( __('download %d:', 'woocommerce' ), $i + 1 );                 } elseif ( $i == 0 )                     echo __( 'download:', 'woocommerce' );                  echo ' <a href="' . $download_file_url . '" target="_blank">' . $filename . '</a></small>';                  $i++;             }         }          // variation         echo    ($item_meta->meta) ? '<br/><small>' . nl2br( $item_meta->display( true, true ) ) . '</small>' : '';      ?></td>     <td style="text-align:left; vertical-align:middle; border: 1px solid #eee;"><?php echo $item['qty'] ;?></td>     <td style="text-align:left; vertical-align:middle; border: 1px solid #eee;"><?php echo $order->get_formatted_line_subtotal( $item ); ?></td> </tr>  <?php if ($show_purchase_note && $purchase_note = get_post_meta( $_product->id, '_purchase_note', true)) : ?>     <tr>         <td colspan="3" style="text-align:left; vertical-align:middle; border: 1px solid #eee;"><?php echo apply_filters('the_content', $purchase_note); ?></td>     </tr> <?php endif; ?> 

and result, email no thumbnail image. i've changed alt attribute , image size several times , worked fine, however, the img src still missing.

<td style="text-align:left;vertical-align:middle;border:1px solid #eee;word-wrap:break-   word"> <img alt="img" height="150" width="150" style="vertical-align:middle;margin-right:10px">prueba test<br><small></small> </td> 

what doing wrong? help!

wc have in code, need enable template file. please woocommerce directory inside theme , go to:

/wp-content/themes/your theme name/woocommerce/emails

find file email-order-details.php , find code.

<?php echo $order->email_order_items_table( array(         'show_sku'      => $sent_to_admin,         'show_image'    => false,         'image_size'    => array( 50, 50 ),         'plain_text'    => $plain_text,         'sent_to_admin' => $sent_to_admin     ) ); ?> 

and replace

<?php echo $order->email_order_items_table( array(         'show_sku'      => $sent_to_admin,         'show_image'    => true,         'image_size'    => array( 50, 50 ),         'plain_text'    => $plain_text,         'sent_to_admin' => $sent_to_admin     ) ); ?> 

all done.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -