If you have the Professional extension, this can be configured right in the PDF invoices settings, in WooCommerce > PDF Invoices > Documents > Invoice > General > Disabled for:
If you are only using the free main plugin, you can achieve this with the following code snippet:
/** * PDF Invoices & Packing Slips for WooCommerce * Disable invoices for orders paid by Cash on Delivery (COD) */ add_filter( 'wpo_wcpdf_document_is_allowed', function( $allowed, $document ) { if ( $order = $document->order ?? false ) { if ( $document->exists() ) { return $allowed; } // Apply this behavior only to the PDF Invoice if ( $document->type === 'invoice' ) { $payment_method = $order->get_payment_method(); if ( $payment_method === 'cod' ) { $allowed = false; } } } return $allowed; }, 10, 2 );
I have the professional extension and this one works too but disables completely the option to create a COD invoice manually after the customer has paid. Is there any workaround to allow the manual creation later and avoid creating it automatically when goes to completed status?
Instead of disabling the document altogether when the payment method is COD, you could skip the invoice automatic attachment only, using the same condition. This can be done with a code snippet too.
Please contact us at [email protected] and I will write a code snippet for you as part of the premium support 😉