• Resolved yergomezz

    (@yergomezz)


    Hello, is it possible to only attach the invoice for certain payment methods?

    For cash on delivery payment I would not like to attach the invoice, how can I do it?

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

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

    (@yordansoares)

    Hi @yergomezz,

    Yes, it is! Please add this code snippet to your site to disable the invoice only for specific payment methods:

    /**
     * Disable the invoice attachment 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_disallowed = ['bacs'];
    		$allowed = ( in_array( $order->get_payment_method(), $payment_methods_disallowed ) ) ? false : true;
    	}
    	return $allowed;
    }, 10, 2 );

    You can add as many payment methods as you want in the $payment_methods_disallowed array. See How to get the id for a Payment Method in WooCommerce.

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

    Let me know if it worked!

Viewing 1 replies (of 1 total)
  • The topic ‘attach the invoice for certain payment methods’ is closed to new replies.