• Resolved jakab1996

    (@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/jakabstore.com/wp-content/uploads/2019/11/Privacy-Policy.pdf = get_template_directory() . '/terms.pdf';
    		$attachments[] = $public_html/jakabstore.com/wp-content/uploads/2019/11/Privacy-Policy.pdf;
    	}
    	return $attachments;
    }

    I followed this instructions:
    attach-static-pdf-to-order-confirmation-email/

    And I got this error message
    Parse error: syntax error, unexpected ‘/’ in /home/legevro0/public_html/jakabstore.com/wp-content/plugins/my-custom-functions/inc/php/functional.php(103) : 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)
  • Thread Starter jakab1996

    (@jakab1996)

    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.

    Thread Starter jakab1996

    (@jakab1996)

    Thanks !!!!

    Thread Starter jakab1996

    (@jakab1996)

    Resolveeeeeeeeeeeeeed <3 ??

Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘Custom Functions ( static pdf to order email)’ is closed to new replies.