Forked from bryceadams/gist:a8e01ad4e1901f849658
Last active
February 23, 2018 19:49
-
-
Save lmartins/9234b5983b62e66fc87d to your computer and use it in GitHub Desktop.
Quick little snippet that will let you add a static PDF file (or in fact, any kind of file) to the WooCommerce Order Emails.
Just add the following code to the ‘custom functions’ area of your functions.php file:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// http://bryceadams.com/add-pdf-woocommerce-order-email/ | |
add_filter( 'woocommerce_email_attachments', 'attach_terms_conditions_pdf_to_email', 10, 3); | |
function attach_terms_conditions_pdf_to_email ( $attachments, $status , $order ) { | |
$allowed_statuses = array( 'new_order', 'customer_invoice', 'customer_processing_order', 'customer_completed_order' ); | |
if( isset( $status ) && in_array ( $status, $allowed_statuses ) ) { | |
$your_pdf_path = get_template_directory() . '/terms.pdf'; | |
$attachments[] = $pdf_path; | |
} | |
return $attachments; | |
} |
You have to change line 9 to:
$your_path = dirname(FILE) . '/terms.pdf';
(If terms.pdf is located at the same level as functions.php)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@renuprv: I think that $file needs to be an absolute path on the web server, not a url.