add_filter( 'woocommerce_email_attachments', 'attach_downloadable_files_to_customer_completed_email', 10, 3 ); function attach_downloadable_files_to_customer_completed_email( $attachments, $email_id, $order ) { if( isset( $email_id ) && $email_id === 'customer_completed_order' ){ // Loop through order items foreach( $order->get_items() as $item ) { $product = $item->get_product(); // The product Object if ( $product->is_downloadable() && ( $downloads = $product->get_downloads() ) ) { // Loop through product downloads foreach( $downloads as $download ) { $attachments[] = $download->get_file(); } } } } return $attachments; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter