• Resolved happyfalcon

    (@happyfalcon)


    Hi,

    I’m currently trying to add an extra PDF-file to the order confirmation email. At the moment I already have plugin for pdf invoice attached to completed order email, but I need to add a static PDF-file (with terms and conditions according to law of my country).

    I tried to look around for previous answers, but couldnt find anything besides really expensive plugins, is there any way to find a free plugin or use custom coding in functions php?

    If somebody knows, could you kindly share the information?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter happyfalcon

    (@happyfalcon)

    @seank123 Thank you, it really does work! only thing i can’t figure out is how to set a condition to attach the pdf only to order emails, because what that code does now is it attaches the pdf to every single type of email(completed order,order on hold, etc.)

    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', 'customer_invoice', 'customer_processing_order', 'customer_completed_order' );
    	if( isset( $id ) && in_array ( $id, $allowed_statuses ) ) {
    		$your_pdf_path = get_template_directory() . '/terms.pdf';
    		$attachments[] = $pdf_path;
    	}
    	return $attachments;
    }
    • This reply was modified 5 years, 4 months ago by crslz.
    Plugin Support Missy a11n

    (@m155y5)

    Automattic Happiness Engineer

    We haven’t heard back from you in a while, but it looks like you received some good suggestions here, so I’m going to go ahead and mark this thread as resolved. If you have any other questions please feel free to start a new thread.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘ATTACH STATIC PDF TO ORDER CONFIRMATION EMAIL’ is closed to new replies.