SHARE
TWEET

Untitled

a guest Jun 17th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3.  * Optionally attach uploaded images to the order email
  4.  */
  5. function pewc_attach_images_to_email( $attachments, $id, $order ) {
  6.  
  7.     if( ( $id == 'new_order' || $id == 'customer_on_hold_order' ) && get_option( 'pewc_email_images', 'no' ) == 'yes' ) {
  8.  
  9.         // Find any attachments
  10.         $order_items = $order->get_items( 'line_item' );
  11.         if( $order_items ) {
  12.             foreach( $order_items as $order_item ) {
  13.                 $product_extras = $order_item->get_meta( 'product_extras' );
  14.                 if( ! empty( $product_extras['groups'] ) ) {
  15.                     foreach( $product_extras['groups'] as $group ) {
  16.                         foreach( $group as $item_id=>$item ) {
  17.                             if( ! empty( $item['file'] ) ) {
  18.                                 $attachments[] = $item['file'];
  19.                             }
  20.                         }
  21.                     }
  22.                 }
  23.             }
  24.         }
  25.  
  26.     }
  27.  
  28.     return $attachments;
  29.  
  30. }
  31. add_filter( 'woocommerce_email_attachments', 'pewc_attach_images_to_email', 10, 3 );
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