• Resolved jazzu

    (@jazzu)


    Hello!

    Last time I wrote on this forum, I found, that I had this code snippet in my functions as a comment, but I didn’t know why I disabled it. The code below works, and it only sends the PDF invoice to customers that use direct bank transfer as their form of payment, however, the code messes up my WooCommerce Orders page. I can’t access the screen options tab in WooCommerce Orders, AND I am only being shown 1 order for some reason. All other orders are hidden. It’s not a cache problem, it’s not a cookies problem, as I also tried, if WooCommerce orders are shown on my phone, but they are not.

    I went ahead and started disabling parts of code, and found that the code below is the reason for this happening.

    /*		PDF Invoice for BACS only		*/
    
    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 );

    Is there another way of getting the code’s function into my website, or any other way I can fix this problem?

    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 alexmigf

    (@alexmigf)

    Hello @jazzu

    Could you please try this one instead?

    add_filter('wpo_wcpdf_document_is_allowed', function( $allowed, $document ) {
    	if ( ! empty( $order = $document->order ) && $document->get_type() == 'invoice' ) {
    		$payment_method_title = is_callable( array( $order,'get_payment_method' ) ) ? $order->get_payment_method() : '';
    		if ( stripos( $payment_method_title, 'bacs' ) === false ) {
    			$allowed = false;
    		}
    	}
    	return $allowed;
    }, 10, 2 );
    Thread Starter jazzu

    (@jazzu)

    Hey @alexmigf !

    Great, this one works perfectly!

    Thank you very much!

    Kind regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Including PDF into WooCommerce email only when payment method is BACS’ is closed to new replies.