SHARE
TWEET

Woocommerce order email template with product photo

nicolaslagios Mar 19th, 2018 158 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3.  * Admin new order email
  4.  *
  5.  * This template can be overridden by copying it to yourtheme/woocommerce/emails/admin-new-order.php.
  6.  *
  7.  * HOWEVER, on occasion WooCommerce will need to update template files and you
  8.  * (the theme developer) will need to copy the new files to your theme to
  9.  * maintain compatibility. We try to do this as little as possible, but it does
  10.  * happen. When this occurs the version of the template file will be bumped and
  11.  * the readme will list any important changes.
  12.  *
  13.  * @see         https://docs.woocommerce.com/document/template-structure/
  14.  * @author WooThemes
  15.  * @package WooCommerce/Templates/Emails/HTML
  16.  * @version 2.5.0
  17.  */
  18.  
  19.  if ( ! defined( 'ABSPATH' ) ) {
  20.     exit;
  21.  }
  22.  
  23.  /**
  24.   * @hooked WC_Emails::email_header() Output the email header
  25.   */
  26.  do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
  27.  
  28.  <p><?php printf( __( 'You have received an order from %s. The order is as follows:', 'woocommerce' ), $order->get_formatted_billing_full_name() ); ?></p>
  29.  
  30.  <?php
  31.  
  32.  /**
  33.   * @hooked WC_Emails::order_details() Shows the order details table.
  34.   * @hooked WC_Structured_Data::generate_order_data() Generates structured data.
  35.   * @hooked WC_Structured_Data::output_structured_data() Outputs structured data.
  36.   * @since 2.5.0
  37.   */
  38. //------------------------------Custom function starts here (nicolaslagios.com)
  39. function sww_add_images_woocommerce_emails( $output, $order ) {
  40.    
  41.     // set a flag so we don't recursively call this filter
  42.     static $run = 0;
  43.  
  44.     // if we've already run this filter, bail out
  45.     if ( $run ) {
  46.         return $output;
  47.     }
  48.  
  49.     $args = array(
  50.     'show_sku'      => true,
  51.     'show_image'    => true,
  52.     'image_size'    => array( 100, 100 ),
  53. );
  54.  
  55.     // increment our flag so we don't run again
  56.     $run++;
  57.  
  58.     // if first run, give WooComm our updated table
  59.     return $order->email_order_items_table( $args );
  60. }
  61. add_filter( 'woocommerce_email_order_items_table', 'sww_add_images_woocommerce_emails', 10, 2 );
  62. //------------------------------Custom function ends here (nicolaslagios.com)
  63.  
  64. do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
  65.  
  66.  /**
  67.   * @hooked WC_Emails::order_meta() Shows order meta data.
  68.   */
  69.  do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
  70.  
  71.  /**
  72.   * @hooked WC_Emails::customer_details() Shows customer details
  73.   * @hooked WC_Emails::email_address() Shows email address
  74.   */
  75.  do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
  76.  
  77.  /**
  78.   * @hooked WC_Emails::email_footer() Output the email footer
  79.   */
  80.  do_action( 'woocommerce_email_footer', $email );
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top