• Resolved jazzu

    (@jazzu)


    Hello!

    Few months ago, I wanted to make the invoice only be sent to people, when they use BACS as the payment method. I added this code:

    /*		PDF Predračun SAMO za BACS		*/
    
    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 );

    The code worked, but now, it won’t even generate the document in the PDF Invoices settings in admin dashboard, and it won’t send it to the customer either.

    I still want the email to only be sent when BACS is selected. What happened to the code, so it doesn’t work anymore?

    Kind regards

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    I think your code may simply be missing some brackets. Could you try this?

    /*		PDF Predračun SAMO za BACS		*/
    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 );
    	}
    	return $allowed;
    }, 10, 2 );

    If that’s not it, the only thing I can think of is that the payment method is not set to BACS?

    Thread Starter jazzu

    (@jazzu)

    Hello @pomegranate !

    That’s great, it works now! Thank you very much!

    Kind regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Problem with code to only send an email when BACS is the form of payment’ is closed to new replies.