Support » Plugin: WooCommerce » Custom Functions ( static pdf to order email)

  • Resolved jakab1996


    I added the following code to “My custom functions” plugin by (spacex-chimp)

    add_filter( 'woocommerce_email_attachments', 'attach_terms_conditions_pdf_to_email', 10, 3);
    function attach_terms_conditions_pdf_to_email ( $attachments , $id, $object ) {
    	$allowed_statuses = array( 'new_order' );
    	if( isset( $id ) && in_array ( $id, $allowed_statuses ) ) {
    		$public_html/ = get_template_directory() . '/terms.pdf';
    		$attachments[] = $public_html/;
    	return $attachments;

    I followed this instructions:

    And I got this error message
    Parse error: syntax error, unexpected ‘/’ in /home/legevro0/public_html/ : eval()’d code on line 5
    The site is experiencing technical difficulties. Please check your site admin email inbox for instructions.

Viewing 4 replies - 16 through 19 (of 19 total)
  • I have a last question. I made a test order with a direct bank transfer. I assume woocommerce sent me on hold order email new order.

    Can you include the on hold order code too.
    It even will not attach the pdfs when I change the order to completed, I guess it only sends it when (new order)

    Yes, if you went straight from On Hold to Complete, you would skip the Processing step and the email attachments would not be included using just “customer_processing_order,” as shown in this schematic.

    The key is in the line of code declaring the array of statuses:

    $allowed_statuses = array('customer_processing_order');

    If you want to attach the files to an “on hold” order as well a “processing order”, I think you need to change that line to:

    $allowed_statuses = array('customer_processing_order', 'customer_on_hold_order');

    Of course, you could just attach the PDFs to a completed order email which would get the order emails once you’ve marked them as completed:

    $allowed_statuses = array('customer_completed_order');

    The key is to make sure you also have the associated emails enabled in WooCommrece.

    Thanks !!!!

    Resolveeeeeeeeeeeeeed <3 🙂

Viewing 4 replies - 16 through 19 (of 19 total)
  • You must be logged in to reply to this topic.