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

    (@yordansoares)

    Hi @alphatechlogix,

    That’s right. The code snippet there should work with the latest version of the main free plugin & paid extensions 🙂

    Thread Starter alphatechlogix

    (@alphatechlogix)

    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;
    }
    Plugin Contributor Yordan Soares

    (@yordansoares)

    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!

    Thread Starter alphatechlogix

    (@alphatechlogix)

    is this snippet also disabled email of invoice for this payment method?

    Plugin Contributor Yordan Soares

    (@yordansoares)

    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).

    Thread Starter alphatechlogix

    (@alphatechlogix)

    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

    Thread Starter alphatechlogix

    (@alphatechlogix)

    i means to say pdf is also not attached for other email as well.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    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.

    Thread Starter alphatechlogix

    (@alphatechlogix)

    Please see i already selected status as well for other emails but none of email have pdf.
    https://tinyurl.com/y4k73hrc

    and i do see also log error it show me only this. and there is no fatal error.
    https://tinyurl.com/y33v8bjf

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Thanks 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

    Thread Starter alphatechlogix

    (@alphatechlogix)

    i am sorry but smtp is working fine, its showing error bcz i install smtp for mail logging

    Plugin Contributor Yordan Soares

    (@yordansoares)

    I see. Could you please write to support@wpovernight.com, so I can continue providing help there? 🙂

    Thread Starter alphatechlogix

    (@alphatechlogix)

    have you recived?

    Thread Starter alphatechlogix

    (@alphatechlogix)

    i disable paid version but still invoice pdf is not attach with any email

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Please follow these steps to find out if the issue occurs before the message is sent:

    1. Install and activate the WP Mail Logging by MailPoet plugin
    2. 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:

      A screenshot that display the Send order email panel from WooCommerce with the Completed order notification selected in the dropdown

    3. 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:

      A screenshot that display the WP Mail Logging plugin log screen

    4. Share the results with us 🙂
Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘Skip invoice creation for specific payment methods’ is closed to new replies.