Skip invoice creation for specific payment methods
-
is it still work with latest and paid version?
https://wordpress.org/support/topic/skip-invoice-creation-for-specific-payment-methods/-
This topic was modified 4 years, 5 months ago by
alphatechlogix.
The page I need help with: [log in to see the link]
-
This topic was modified 4 years, 5 months ago by
-
Hi @alphatechlogix,
That’s right. The code snippet there should work with the latest version of the main free plugin & paid extensions 🙂
i found one more code from one of your college. which one will work perfectly?
add_filter( 'wpo_wcpdf_document_is_allowed', 'wpo_wcpdf_disable_invoice_for_certain_payment_methods', 10, 2 ); function wpo_wcpdf_disable_invoice_for_certain_payment_methods ( $condition, $document ) { if ( $document == 'invoice' ) { $disabled_methods = array('stripe', 'bacs'); $payment_method = $order->get_payment_method(); if ( in_array( $payment_method, $disabled_methods ) ) $condition = false; } return $condition; }Use this one instead:
/** * Disable invoices based on payment method */ add_filter( 'wpo_wcpdf_document_is_allowed', 'wpo_wcpdf_invoice_based_on_payment_method', 10, 2 ); function wpo_wcpdf_invoice_based_on_payment_method( $allowed, $document ) { if ( $order = $document->order ) { if ( $document->exists() ) { return $allowed; } if ($document->type == 'invoice') { $payment_method = $order->get_payment_method(); $disalled_payment_method = [ 'stripe', 'bacs']; // add here the payment method ids you want to disable $allowed = ( in_array($payment_method, $disalled_payment_method) ) ? false : true; } } return $allowed; }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 worked!
is this snippet also disabled email of invoice for this payment method?
Yes, this code snippet disable the document and the email attachment as well, for the payment method(s) that you set in
$disalled_payment_method('stripe'and'bacs'in the code snippet above).but i am not able to recieve email for other payment methods as well, can you please guide me for debugging as well as for proper setting
i means to say pdf is also not attached for other email as well.
Hi @alphatechlogix,
Do you have selected the WooCommerce email notifications in which you want to attach the invoice, under WooCommerce > PDF Invoices > Documents > Invoice > Attach to? Here you’ll find all the email notifications available in your site.
Please note that when a document is attached to an email, this action will create an invoice number immediately, so my recommendation is only select here the notifications related with order statuses in which you have received the payment, like Processing order or Completed order.
Please see i already selected status as well for other emails but none of email have pdf.
https://tinyurl.com/y4k73hrcand i do see also log error it show me only this. and there is no fatal error.
https://tinyurl.com/y33v8bjfThanks for sharing those screenshots. In the first one, I can see an admin notice that say Postman is not configured. It’s likely that your issue is related with the mail sending. My recommendation is to finish the set-up of SMTP and try again.
As I just realized that you’re using Professional and Premium Templates extensions, and since WordPress doesn’t allow us to provide premium support for paid plugins here, please let’s follow this conversation in support@wpovernight.com
i am sorry but smtp is working fine, its showing error bcz i install smtp for mail logging
I see. Could you please write to support@wpovernight.com, so I can continue providing help there? 🙂
have you recived?
i disable paid version but still invoice pdf is not attach with any email
Please follow these steps to find out if the issue occurs before the message is sent:
- Install and activate the WP Mail Logging by MailPoet plugin
- Open an existent order, find the Send order email panel, on the right side, select one of the email notification in which you attach the invoice, e.g. Complete order, and click on Save order and send email:

- Then go to Tools > WP Mail Log, find your last email, and check if there are files in the Attachments column, and/or any notice on the Error column:

- Share the results with us 🙂
The topic ‘Skip invoice creation for specific payment methods’ is closed to new replies.