• Resolved jazzu

    (@jazzu)


    Hello!

    I need the PDF invoice to ONLY be attached to the customer-on-hold-order email. I selected the email, so that’s the only email that it attaches to.

    However, I need it to be even more specific – I need the PDF to be attached ONLY if payment method is Direct Bank Transfer.

    What’s the best approach for me to do this?

    Kind regards

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @jazzu,

    To achieve what you want, please add this code snippet to your site:

    /**
     * Enable the invoice attachment only for specific payment methods
     */
    add_filter( 'wpo_wcpdf_document_is_allowed', function ( $allowed, $document ) {
    	if ( $order = $document->order && $document->type == 'invoice') {
    		// Set the payment method IDs below
    		$payment_methods = ['bacs'];
    		$allowed = ( in_array( $order->get_payment_method(), $payment_methods ) ) ? true : false;
    	}
    	return $allowed;
    }, 10, 2 );

    If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters

Viewing 1 replies (of 1 total)
  • The topic ‘Need the PDF invoice to only be attached to email IF payment method is BACS’ is closed to new replies.