Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Optionally attach uploaded images to the order email
- */
- function pewc_attach_images_to_email( $attachments, $id, $order ) {
- if( ( $id == 'new_order' || $id == 'customer_on_hold_order' ) && get_option( 'pewc_email_images', 'no' ) == 'yes' ) {
- // Find any attachments
- $order_items = $order->get_items( 'line_item' );
- if( $order_items ) {
- foreach( $order_items as $order_item ) {
- $product_extras = $order_item->get_meta( 'product_extras' );
- if( ! empty( $product_extras['groups'] ) ) {
- foreach( $product_extras['groups'] as $group ) {
- foreach( $group as $item_id=>$item ) {
- if( ! empty( $item['file'] ) ) {
- $attachments[] = $item['file'];
- }
- }
- }
- }
- }
- }
- }
- return $attachments;
- }
- add_filter( 'woocommerce_email_attachments', 'pewc_attach_images_to_email', 10, 3 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement